Images.jl icon indicating copy to clipboard operation
Images.jl copied to clipboard

Changing compression level when saving image as jpg

Open michael-prange opened this issue 5 years ago • 4 comments

The documentation says that save() allows options to be set, but it doesn't say how to change the compression level when saving an image as jpg. The documentation "save(f, data...; options...) passes keyword arguments on to the saver" seems to suggest that options are accepted, but doesn't describe these options.

michael-prange avatar Oct 29 '19 01:10 michael-prange

This is not documented clearly. FileIO.save passes all keyword options to the real function, so you might need to find what's supported in image IO backends. Unfortunately, neither ImageMagick.jl and QuartzImageIO.jl document this.

If you're using ImageMagick.jl as the backend, you can pass quality as a keyword argument as the source code suggests.

julia> save("cameraman_100.jpg", img, quality=100)

julia> save("cameraman_1.jpg", img, quality=1)

jc@mathlf1:~/D/test $ du -sh *
4.0K	cameraman_1.jpg
108K	cameraman_100.jpg

As for QuartzImageIO.jl, looks like there isn't such a keyword. Issue filed https://github.com/JuliaIO/QuartzImageIO.jl/issues/57 @rsrock

johnnychen94 avatar Oct 29 '19 19:10 johnnychen94

Want to submit a PR updating the README for https://github.com/JuliaIO/ImageMagick.jl, @michael-prange?

timholy avatar Oct 30 '19 19:10 timholy

I don’t know how to do that. I just wanted to let the developers know that the documentation could use a bit of improvement. I love the package, but I had to read the code in order to find out about the quality option. Purpose of documentation is to avoid forcing everyone to read the code in order to use it most productively.

Sent from my iPad

On Oct 30, 2019, at 15:19, Tim Holy [email protected] wrote:

 Want to submit a PR updating the README for https://github.com/JuliaIO/ImageMagick.jl, @michael-prange?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

michael-prange avatar Oct 30 '19 21:10 michael-prange

https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github/

You can edit the README.md file in your web browser, no special skills required. Developers are people just like you!

timholy avatar Oct 30 '19 21:10 timholy