Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20257] Windows: Support Ti.Blob.imageAs* methods

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-02-05T14:32:18.000+0000
Affected Version/sRelease 5.2.0
Fix Version/sRelease 5.3.0
ComponentsWindows
Labelswindows, windows_phone
ReporterAlberto Bonacina
AssigneeKota Iguchi
Created2016-01-20T13:51:30.000+0000
Updated2018-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.

Comments

  1. Christopher Williams 2016-01-20

    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
  2. Kota Iguchi 2016-02-04

    https://github.com/appcelerator/titanium_mobile_windows/pull/547
  3. Christopher Williams 2016-02-05

    [~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?
  4. Ewan Harris 2016-05-23

    [~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?
  5. Christopher Williams 2016-05-23

    [~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...
  6. Ewan Harris 2016-05-24

    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

JSON Source