[MOD-2928] ImageFactory: Add WebP format support
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-10-19T23:49:23.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | ImageFactory |
Labels | ImageFactory, android, compress, image, webp |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2021-09-15T04:11:50.000+0000 |
Updated | 2021-10-19T23:49:23.000+0000 |
Description
*Summary:*
We should add ".webp" image format support to the "ti.imagefactory" module on Android.
*Proposed Solution:*
All transformation methods such as
imageAsRotated()
, imageAsResized()
, etc. already support a "format" option which can be set to ImageFactory.JPEG
or ImageFactory.PNG
. We should add a new ImageFactory.WEBP
constant and support compressing to that format.
We should also add a 3rd optional argument to the compress()
method. Currently, this method defaults to JPEG, but this will allow it be formatted to WEBP or PNG as well.
compress(blob, quality [, format ])
The following Android-only method should look at the "fileUrl" argument's file extension to determine which image format to compress to. That is, if the file extension is .webp
, then it should compress to WebP.
compressToFile(blob, quality, fileUrl)
*Note:*
iOS does not natively support the WebP image file format. This will be an Android only feature.
PR (ti.imagefactory): https://github.com/appcelerator-modules/ti.imagefactory/pull/192
Added to release... https://github.com/appcelerator-modules/ti.imagefactory/releases/tag/v5.1.0-android