[TIMOB-20257] Windows: Support Ti.Blob.imageAs* methods
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-02-05T14:32:18.000+0000 |
Affected Version/s | Release 5.2.0 |
Fix Version/s | Release 5.3.0 |
Components | Windows |
Labels | windows, windows_phone |
Reporter | Alberto Bonacina |
Assignee | Kota Iguchi |
Created | 2016-01-20T13:51:30.000+0000 |
Updated | 2018-10-10T16:30:05.000+0000 |
Description
On windows phone I have to make some image manipulation, in my case I want to resize/reduce quality of an image before upload it on my server. On Android/iOS I use [ti.imagefactory](http://gitt.io/component/ti.imagefactory) and everything works as expected with this function that I made for a little manipulation on the image before upload it:
Alloy.Globals.imageMaxDimensione = 500;
Alloy.Globals.imageQuality = 0.9;
function resizeImageForUpload(imageBlob){
_altezza = imageBlob.getHeight();
_larghezza = imageBlob.getWidth();
_newLarghezza = 0; _newAltezza = 0;
if(_altezza > _larghezza){ //portrait
_newAltezza = Alloy.Globals.imageMaxDimensione;
_newLarghezza = Math.floor(Alloy.Globals.imageMaxDimensione*_larghezza/_altezza);
} else { //sono in landscape
_newLarghezza = Alloy.Globals.imageMaxDimensione;
_newAltezza = Math.floor(Alloy.Globals.imageMaxDimensione*_altezza/_larghezza);
}
var ImageFactory = require('ti.imagefactory');
var dict = {
width: _newLarghezza,
height: _newAltezza,
quality: Alloy.Globals.imageQuality
};
newBlob = ImageFactory.imageAsResized(imageBlob,dict);
return newBlob;
}
but on windows phone I haven't ti.imagefactory library. As a workaround I could use [Titanium.Blob.imageAsResized](http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Blob-method-imageAsResized) but this function is not supported on Windows Phone.
Is it possible to include in future update a compatibility with Windows Phone for the function used to manipulate images? The best in this case will be ti.imagefactory also for Windows Phone.
Some possible pointers on resizing/scaling/cropping using WinRT APIs: - https://social.msdn.microsoft.com/Forums/en-US/2437d485-ac7c-4a94-bfba-2e4b8e8039cf/high-quality-image-resizing-in-winrt?forum=winappswithcsharp - http://stackoverflow.com/questions/12349611/how-to-resize-image-in-c-sharp-winrt-winmd We may want to transform this ticket into supporting Ti.Blob.imageAsResized( width, height ) and Ti.Blob.imageAsCropped( options ): - http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Blob-method-imageAsResized - http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Blob-method-imageAsCropped
https://github.com/appcelerator/titanium_mobile_windows/pull/547
[~bimmel] Please note that Ti.Blob.imageAsThumbnail doesn't support/ignores the borderSize and cornerRadius arguments. [~gmathews] Can we specify constraints/notes like this in the xml files in acidic folder? How would we add details like this?
[~kota] [~cwilliams] While testing this I found the following issue TIMOB-23425 where the application crashes when the blob used does not represent a blob, according to the docs the method should just return null. Should this be fixed for 5.3.0?
[~eharris] I'd argue that it's not a regression and the workaround is to not call it for non-images :) But it certainly is a bad bug and we should fix it for 5.4.0 if we can...
Agreed (y) Just wanted to be 100% sure it was a post 5.3.0 ticket. I'll go ahead and close this. Windows 10 Pro Visual Studio 2015 Community Update 2 Appc Core: 5.3.0-46 Appc NPM: 4.2.5-5 Ti SDK: 5.3.0.v20160523083840 Lumia 520 8.1, Lumia 930 10.0 Ti.Blob.imageAs methods are now implemented and work as expected Closing ticket