appengine-java-standard icon indicating copy to clipboard operation
appengine-java-standard copied to clipboard

ImageService.composite - Overlaying a transparent PNG no longer works as expected

Open codeconsole opened this issue 1 year ago • 4 comments

I have used the following for the past 10 years for watermarking an image. Its behavior stopped working correctly on 5/10/24 and has been broken ever since. Previously it would lay a transparent PNG on top of a photo, but now the non-transparent parts of the PNG are 100% white. What changed 5/10/24 that broke everything?

Image originalImage = ImagesServiceFactory.makeImageFromFilename(...)

List<Composite> listComposites = new ArrayList<>();
listComposites.add(ImagesServiceFactory.makeComposite(originalImage, 0, 0, 1, Composite.Anchor.TOP_LEFT));

Image wmk = imagesService.applyTransform(ImagesServiceFactory.makeResize(width, height),
    ImagesServiceFactory.makeImage(toByteArray(new ClassPathResource("watermark/watermark.png").getInputStream())),
    ImagesService.OutputEncoding.PNG);
listComposites.add(ImagesServiceFactory.makeComposite(wmk, 0, 0, 1, Composite.Anchor.CENTER_CENTER));

return imagesService.composite(listComposites, width, height, 0xFFFFFFFFL, ImagesService.OutputEncoding.JPEG);

codeconsole avatar Jun 17 '24 06:06 codeconsole

I doubt it is a client side bug, I need to investigate with the backend team, or an automatic JDK change? Just to be sure: which java runtime are you using? Did you try another one?

ludoch avatar Jun 22 '24 08:06 ludoch

The app was java8. It started occurring continuously on 5/10/24 after running successfully for years. Same result after migrating to java21. Most likely a backend issue because I don't see anything in the ImageService java code that would cause it.

codeconsole avatar Jun 22 '24 16:06 codeconsole

Can you share the AppId/Projectd and service/version names? SREs would like to see some backend logs

ludoch avatar Jul 09 '24 17:07 ludoch

It was a nasty issue and I didn't have time to wait for it to get fixed. I since removed my dependency on ImagesServiceFactory and now do all of the watermarking using java directly. I can probably create a sample app to replicate the issue when I get some time, but it wasn't random and happened every time so it should be easy for you guys to replicate.

codeconsole avatar Jul 12 '24 05:07 codeconsole

The image server backend pushed a fix that should be in prod now. Can you try again. Sorry for this regression

ludoch avatar Sep 25 '24 15:09 ludoch