function cropFromMiddleAndResize(aBlob) {
var newBlob = null;
var px;
var py;
var width;
var height;
var mediawidth = aBlob.width;
var mediaheight = aBlob.height;
var resize = 150;
if (mediawidth > mediaheight) {
px = (mediawidth - mediaheight) / 2;
py = 0;
width = mediaheight;
height = mediaheight;
} else {
py = (mediaheight - mediawidth) / 2;
px = 0;
width = mediawidth;
height = mediawidth;
}
var tempimage = (OS_IOS) ? (aBlob.imageAsResized(mediawidth, mediaheight)) : (aBlob);
//https://jira.appcelerator.org/browse/TIMOB-4865
newBlob = tempimage.imageAsCropped({
width : width,
height : height,
x : px,
y : py
});
newBlob = newBlob.imageAsResized(resize, resize);
return newBlob;
}
Friday, 16 January 2015
Image crop and resize
Subscribe to:
Posts (Atom)