Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically save/convert image to webp format

Can bitmap be converted or saved to the webp format in android?

I search out for that but it turns out to be a dead end for me.

I need to save image to webp formate or else need to save in PNG/JPEG then convert to webp programmatically.

like image 227
Vivek Faldu Avatar asked Jan 28 '23 04:01

Vivek Faldu


1 Answers

You can use CompressFormat.WEBP to encode any bitmap in WEBP format.

Example:

FileOutputStream out = new FileOutputStream(path); 
bitmap.compress(Bitmap.CompressFormat.WEBP, 100, out);
out.close();
like image 161
Nabin Bhandari Avatar answered Jan 31 '23 20:01

Nabin Bhandari