Nativescript: [Question] Difference between image-asset and image-source?

Created on 22 Nov 2016  路  3Comments  路  Source: NativeScript/NativeScript

I see no documentation for image-asset and I am unable to find the difference between them. I am aware of iOS PHAsset that delivers "assets". Is this module to be used with native image assets, and what is the purpose of this module compared to image-source?

To clarify my question. Is this the same:

// var nativeAsset = [PHAsset for iOS and something else for Android];
var asset = new imageAsset.ImageAsset(nativeAsset);
test.options = { width: 100, height: 100, keepAspectRatio: false };

asset.getImageAsync(function(image, error) {
  var newImage = imageSource.fromNativeSource(image);
});

As this (iOS)?

var manager = PHImageManager.defaultManager();
var options = PHImageRequestOptions.alloc().init();

options.resizeMode = PHImageRequestOptionsResizeModeFast;
options.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
// options.synchronous = true; // Should be false because of ImageAsset.getImageAsync()?

manager.requestImageForAssetTargetSizeContentModeOptionsResultHandler(asset, CGSizeMake(100, 100), PHImageContentModeAspectFill, options, function(result, info) {
  var newImage = imageSource.fromNativeSource(result);
});

Except that image-asset handles both platforms?

question

All 3 comments

Hi @NordlingArt

You can take a look at the implementation of image-asset for iOS here and indeed one of the reasons for introducing the image-asset module is to handle the work with PHAsset which is required in order to work with iOS Photo framework. Also, a lot of optimizations were introduced as well.

There is some documentation here: http://docs.nativescript.org/api-reference/modules/_image_asset_.html

Though I would like to see some official examples and usage documented like under this page: https://docs.nativescript.org/ui/images

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings