Skip to content

Commit 8e39b76

Browse files
committed
jpeg_encode: set default quality to 92
Since this package is meant to replace ImageMagick.jl, we use ImageMagick's default value 92 as our default compress quality so that people don't see a too breaking result. From http://www.imagemagick.org/script/command-line-options.php#quality : > The default is to use the estimated quality of your input image if it can be determined, otherwise 92.
1 parent f4cd50c commit 8e39b76

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/encode.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ in memory as return value.
1111
1212
- `transpose::Bool`: whether we need to permute the image's width and height dimension
1313
before encoding. The default value is `false`.
14-
- `quality::Int`: Constructs JPEG quantization tables appropriate for the indicated
15-
quality setting. The quality value is expressed on the 0..100 scale recommended by IJG.
14+
- `quality::Int`: Constructs JPEG quantization tables appropriate for the indicated quality
15+
setting. The quality value is expressed on the 0..100 scale recommended by IJG. The
16+
default value is `92`. Pass `quality=nothing` to let libjpeg-turbo dynamicly guess a
17+
value.
1618
1719
!!! info "Custom compression parameters"
1820
JPEG has a large number of compression parameters that determine how the image is
@@ -28,10 +30,10 @@ julia> using JpegTurbo, TestImages
2830
julia> img = testimage("cameraman");
2931
3032
julia> jpeg_encode("out.jpg", img) # write to file
31-
28210
33+
51396
3234
3335
julia> buf = jpeg_encode(img); length(buf) # directly write to memory
34-
28210
36+
51396
3537
```
3638
3739
# References
@@ -60,7 +62,8 @@ jpeg_encode(io::IO, img; kwargs...) = write(io, jpeg_encode(img; kwargs...))
6062
function _encode(
6163
img::Matrix{<:Colorant};
6264
colorspace::Union{Nothing,Type} = nothing,
63-
quality::Union{Nothing,Int} = nothing,
65+
# ImageMagick: "the default is to use the estimated quality of your input image if it can be determined, otherwise 92."
66+
quality::Union{Nothing,Int} = 92,
6467
arith_code::Union{Nothing,Bool} = nothing,
6568
optimize_coding::Union{Nothing,Bool} = nothing,
6669
smoothing_factor::Union{Nothing,Int} = nothing,

0 commit comments

Comments
 (0)