Open Converted PNG Image

Hi guys!


So, a big problem now, really, it’s very complicated problem.

After I open and optimize a PNG image using Aspose Java Imaging, if I try open this saved image in PHP using GD2 library, an error is occurs. This saved image open correct at any image viewers like Photoshop, Mac OSx Image Preview, Windows Image Viewers and others image editor and previews.

The PHP GD2 library use the libpng (http://www.libpng.org). If I open this saved image using libpng, the error has been returned “Extra compressed data”. The extra compressed data is extra space containeds at image content, may otherwise be used as a Trojan Horse.

Libpng C Code:
https://github.com/glennrp/libpng/blob/a0e3160ad498cadb63ce5df095f7dcf2416f1a5c/pngrutil.c#L721
https://github.com/glennrp/libpng/blob/a0e3160ad498cadb63ce5df095f7dcf2416f1a5c/pngrutil.c#L4102

For simulate the problem, these steps are required.

1. Use Aspose Java Imaging to open, modify and save the PNG image file:
String path = new File(“.”).getCanonicalPath() + “\images\”;
PngImage image = new PngImage((path + “original.png”));
PngOptions options = new PngOptions();
image.setTransparentColor(Color.getTransparent());
image.setTransparentColor(true);
options.setColorType(PngColorType.TruecolorWithAlpha);
options.setCompressionLevel(5);
options.setFilterType(PngFilterType.Adaptive);
image.save((path + “compacted.png”), options);
image.close();

2. Open the PNG image file saved at PHP (5.2, 5.4, 5.6 or anything):
<span style=“font-family: “Courier New”; font-size: small;”>$content = file_get_contents(‘compacted.png’);
<div style=“font-size: small; font-family: “Courier New”;”>$resource = imagecreatefromstring($content);
<div style=“font-size: small; font-family: “Courier New”;”>imagepng($resource, null, 0);<div style=“font-size: small; font-family: “Courier New”;”>imagedestroy($resource);<div style=“font-size: small; font-family: “Courier New”; font-style: italic;”>
<div style=“font-size: small; font-family: “Courier New”; font-style: italic;”>And vuola! The error is occurs on the PHP:<div style=“font-size: small; font-family: “Courier New”;”>exception ‘PhpInternalException’ with message '[Warning] imagecreatefromstring(): gd-png: fatal libpng error: Extra compressed data.<div style=“font-size: small; font-family: “Courier New”;”>
<div style=“font-size: small; font-family: “Courier New”;”>But look now, this is the best part of the problem. This error is not occurs with all PNG image files, only with a few files. This image is a example that occurs:<div style=“font-size: small; font-family: “Courier New”;”>https://drive.google.com/open?id=0B0mpguk3CYW0dEh1dHZrVkwtbnc<div style=“font-size: small; font-family: “Courier New”;”>
Well, this is my problem now. Any ideas about this?

Hi Maicon,

Thank you for your inquiry.

This is to update you that the issue you have described has been logged into our issue tracing system with ID IMAGINGJAVA-639. Our product team will look into it and provide feedback. We will update you with the feedback via this forum thread. Please be patient and spare us little time as this involves thorough investigation.

Hi Maicon,

Please download the latest version Aspose.Imaging for Java 17.03 and try it at your end. The issue has been fixed. We have tested it with the latest version. We are unable to reproduce the issue.

In case the issue persists, feel free to update us along with details.

Hey Ikram,

Thank you, the problem was solved. I'm test using the same steps described at another post, but the problem does not occurs.

Thanks for support!
Hi Maicon,

Thank you for update. It is good to know that the issue has been resolved.

The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.