The change from PngOptions.CompressionLevel to PngOptions.PngCompressionLevel introduces a different way to specify compression settings. The previous integer values (0-9) are replaced by an enumeration that defines specific compression levels.
Solution
To match the old CompressionLevel values to the new PngCompressionLevel enum, you can use the following mapping:
0: PngCompressionLevel.ZipLevel0
1: PngCompressionLevel.ZipLevel1
2: PngCompressionLevel.ZipLevel2
3: PngCompressionLevel.ZipLevel3
4: PngCompressionLevel.ZipLevel4
5: PngCompressionLevel.ZipLevel5
6: PngCompressionLevel.ZipLevel6
7: PngCompressionLevel.ZipLevel7
8: PngCompressionLevel.ZipLevel8
9: PngCompressionLevel.ZipLevel9
You can set the PngCompressionLevel in your code like this:
Code
PngOptions options = new PngOptions();
options.PngCompressionLevel = PngCompressionLevel.ZipLevel9; // For maximum compression
Next Steps
Review your existing code to identify where CompressionLevel is used.
Replace it with the corresponding PngCompressionLevel enum value based on the mapping provided.
Test your implementation to ensure the desired compression behavior is achieved.
If you have any further questions or need additional assistance, please feel free to ask!
Then, I assume that PngCompressionLevel.DeflateRecomended sits beside ZipLevel9 because when converting the above Jpeg sample to Png, both DeflateRecomended and ZipLevel9 will make the image with the same size! Am I correct?
Best.
@australian.dev.nerds
The problem is in the decoding of color spaces in a particular image.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): IMAGINGNET-7747
Files that don’t use this particular color space should convert correctly.
–
Not exactly. ZipLevel and DeflateRecomended use different deflate algorithms.
According to the internal testing DeflateRecomended typically falls somewhere between ZipLevel 8 and 9.
This value mainly depends on the source image and how much it can be compressed.
However, due to the use of a different deflate algorithm, DeflateRecommended performs noticeably faster than ZipLevel.
Considering all of the above, this algorithm was chosen as the recommended option, despite the lack of compression level customization.
Best regards.