I am using play framework 1.2.4. I am having a problem with Image.resize() method that is removing transparency in png images?
My code looks like this:
public static void uploadPhoto(int user_id, File picture) throws IOException{
Images.resize(picture, picture, 200, 200, true);
FileInputStream f = new FileInputStream(picture);
user.getPerson().setPicture(IOUtils.toByteArray(f));
user.getPerson().save();
...
}
I would like to know how to do resize without losing PNG transparency?
Thanks.
Looking at the source code for
play.libs.Imageshttps://github.com/playframework/play/blob/master/framework/src/play/libs/Images.java, when the new sized image is set up (line 102), the image is defaulted to a White background. This looks like why your transparency is being lost.I guess this is a bug.