Closed Bug 986229 Opened 10 years ago Closed 6 years ago

create image resize/crop utility in shared/js

Categories

(Firefox OS Graveyard :: Gaia, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: bkelly, Unassigned)

References

Details

Attachments

(1 file)

I believe we have a number of apps that need to resize images for various reasons.  Off the top of my head I can think of gallery, camera, and contacts.  There are probably more.

In bug 983885 I proposed a shared/js/media/resize_image.js function based on what contacts currently does and suitable for uplift to v1.3.

Unfortunately, in order to be uplift compatible this implementation could not use our fancy new API in bug 854795.  Because of this David requested that we only land the common function in contacts for now.

I'm opening this bug to track unifying our image resizing in a shared function in the future.  I think this would help as it seems fairly tricky to properly clean things up and the APIs are changing.
Here was my initial attempt at the shared resizeImage() function.  I think the API is pretty good, but we need to adjust the guts of the routine to use the new, more memory efficient decode-and-downsample techniques.
See Also: → 983885
Although I agree on this matter, I think the transformation function is a little bit oversized for our purposes. It should be great if we could call draw() only with the output size as it is the main purpose of a resize utility. Furthermore, usually the developer could use this as an intermediate step in order to do something with the result so it should be quite convenient to autodetect the source (dataURL, blob, img, canvas) and return the result in the same format.

Just my opinion.
(In reply to Salvador de la Puente González [:salva] from comment #2)
> Although I agree on this matter, I think the transformation function is a
> little bit oversized for our purposes. It should be great if we could call
> draw() only with the output size as it is the main purpose of a resize
> utility.

Hmm, I guess it should be called resizeAndCropImage().  I made this function to handle the three cases used in contacts.  These functions want to potentially select a sub-section of the source image to then resize to the new image size.
Summary: create resizeImage() utility in shared/js → create image resize/crop utility in shared/js
Oh, for sure. I realized that, then why not provide some example functions with the most common operations such as resize, crop and resizeAndCrop. I think you can leave the name as resize. It is informative enough. We could have a signature where passing the parameters of the transformation function as parameters just before the callback OR simply, use bind. WDYT?
I think that makes a lot of sense.  I have not done that yet, though, as I'm not sure of all the ways our various apps like to resize/crop.  From talking with David I got the impression that there might be some common ways this is done, but I haven't investigated them yet.  Unfortunately ENOTIME at the moment.

It would be nice if we could incorporate a common function when we start porting apps to the new decode-and-downsample API stuff.  If we could unify the implementation then we can ensure they are all doing it correctly.
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: