Skip to content

com.sksamuel.scrimage.nio.PngWriter.NoCompression writes max compressed PNG images #320

@andynugent

Description

@andynugent

In the function com.sksamuel.scrimage.nio.PngWriter.write(AwtImage, ImageMetadata, OutputStream) when the compression level is zero, the switch statement falls through to the default and the compression is set to mode=MODE_EXPLICIT and quality=0.0 (e.g. the same as for MaxCompression).

I've only noticied this for PNGs with NoCompression, but I think it's a general problem for any value between 2 and 8 as well, e.g.

compressionLevel = 9 results in param.setCompressionQuality(0.0f) (0.0 is highest compression)
compressionLevel = 8 results in param.setCompressionQuality(8 / 10f)
...
compressionLevel = 2 results in param.setCompressionQuality(2 / 10f)
compressionLevel = 1 results in param.setCompressionQuality(1.0f) (1.0 is lowest compression)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions