Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6657] Create WebP images on Andriod

GitHub Issuen/a
TypeNew Feature
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterMichael Gangolf
AssigneeAbir Mukherjee
Created2020-12-27T14:45:39.000+0000
Updated2021-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();

Comments

  1. Michael Gangolf 2020-12-27

    PR: https://github.com/appcelerator/titanium_mobile/pull/12358
  2. Joshua Quick 2021-10-19

    *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

JSON Source