[AC-6657] Create WebP images on Andriod
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | n/a |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | n/a |
| Reporter | Michael Gangolf |
| Assignee | Abir Mukherjee |
| Created | 2020-12-27T14:45:39.000+0000 |
| Updated | 2021-10-19T23:50:59.000+0000 |
Description
Be able to create a WebP image on Android
var win = Ti.UI.createWindow({
title: "img",
backgroundColor: '#fff',
layout: "vertical",
exitOn
});
var file = Ti.Filesystem.getFile("img.jpg");
var img1 = Ti.UI.createImageView({
image: file,
width: 400,
height: Ti.UI.SIZE,
top: 10
});
win.add(img1);
console.log("JPG filesize: ", file.size);
// create webp
var blob = file.read();
var webp = blob.imageAsWebP(0.5);
console.log("WebP filesize: ", webp.size);
var img = Ti.UI.createImageView({
image: webp,
width: 400,
height: Ti.UI.SIZE,
top: 10
});
win.add(img);
Ti.App.addEventListener("pause",function(e){
console.log("pause");
})
win.open();
PR: https://github.com/appcelerator/titanium_mobile/pull/12358
*Side Note:* WebP image format support was added to "ti.imagefactory" v5.1.0. https://github.com/appcelerator-modules/ti.imagefactory/releases/tag/v5.1.0-android