1) resize images to a preferred size with acceptable on-device processing times
2) cross platform solution (mainly compatibility with android)
Using an iPhone 4 (running iOS6) as a minimum required device, I started with:
mobilePickPhoto "camera",1000,1000
After snapping a picture in iOS camera overlay, time was measured from the moment the "Use" button was pressed to returning to the card from which mobilePickPhoto was initiated. The above method resulted in times of approximately 4 seconds, which is acceptable.
Since setting the maximum image dimensions of mobilePickPhoto is not supported by Android, I began investigating alternatives. The first method was to resize the photo after the image was obtained by mobilePickPhoto using the following:
Code: Select all
--For resizing images
function mk_makeratio tW,tH,w,h
put min (tW/w,tH/h) into tscaleFactor
return round(w * tscaleFactor) & "," & round(h * tscaleFactor)
end mk_makeratio
on mouseUp
-- Pick photo from phone
mobilePickPhoto "camera"
if it is "cancel" then
exit mouseUp
end if
-- Resizing
put the formattedwidth of last image into w
put the formattedheight of last image into h
put 1000 into tW
put 1000 into tH
put mk_makeratio(tW,tH,w,h) into new_imagesize
put item 1 of new_imagesize into newW
put item 2 of new_imagesize into newH
lock screen
set the width of last image to newW
set the height of last image to newH
set the imagedata of last image to the imagedata of last image
unlock screen
end mouseUp
set the resizeQuality of the templateImage to "best"
before the mobilePickPhoto statement (in order to optimize image quality of the resized image), processing times skyrocket to 1 min 13 secs. Adding this line when setting maximum image size of mobilePickPhoto has little to no effect on processing time.
My next option was to not resize after the fact and set the size properties of templateImage. For testing purposes I chose 747x1000 which is proportional to the native full size portrait image captured by the camera. Here's what I used:
Code: Select all
on mouseUp
--Set templateImage properties that mobilePickPhoto is base on
set the width of the templateImage to 747
set the height of the templateImage to 1000
set the lockloc of the templateImage to true
-- Pick photo from phone
mobilePickPhoto "camera"
if it is "cancel" then
exit mouseUp
end if
lock screen
set the imagedata of last image to the imagedata of last image
unlock screen
end mouseUp
Since it is obvious that the hardware can handle reasonable processing times when setting the maximum image size property of mobilePickPhoto, I'm at a loss as to why alternate methods take so much longer. If there are no other alternatives, it will severely compromise the ability of the intended app to provide a cross-platform solution.
Can anyone confirm these observations?
Can someone suggest an alternate resizing method I can try?
Thanks in advance.