-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParseGeometry() can't digest chroma subsampling formatted by MagickSetSamplingFactors() #4793
Comments
Use colons instead of commas to delimit the contents of _ImageInfo::sampling_factors, e.g. 4:2:0 instead of 4,2,0, see issue ImageMagick#4793. Signed-off-by: Jan Lindemann <[email protected]>
Thanks for the problem report. We can reproduce it and will have a patch to fix it in the GIT main branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://imagemagick.org/download/beta/ by sometime tomorrow. |
Use colons instead of commas to delimit the contents of _ImageInfo::sampling_factors, e.g. 4:2:0 instead of 4,2,0, see issue #4793. Signed-off-by: Jan Lindemann <[email protected]> Co-authored-by: Cristy <[email protected]>
Manually closing this issue: c506c6a was merged by @urban-warrior through the commits 6d69fce / 73901f2. Thank you! |
ImageMagick version
51f487a / Current Git master
Operating system
Linux
Operating system, version and so on
Any
Description
Among other things,
ParseGeometry()
is designed to parse chroma subsampling definition strings, and its description states: "Values may also be separated by commas, colons, or slashes, and offsets". Consequently, it's used to interpret_ImageInfo::sampling_factor
from various pieces of code decoding and encoding images.ParseGeometry()
correctly converts the argument string into sampling factors if the argument is in the form ofa:b:c
. It doesn't, however, correctly convert subsampling definitions in the form ofa,b,c
, and_ImageInfo::sampling_factor
sometimes contains just that, notably if set byMagickSetSamplingFactors()
.ParseGeometry()
doesto check if it should normalize
sigma
andrho
. This obviously evaluates to false if ',' is used as a delimiter and omits normalization. See the output of the (attached) test-geometry:I suspect the reason why this was never noticed is that the command-line tools use the core API and set
_ImageInfo::sampling_factor
string taken from the command-line, i.e. asa:b:c
, which is the widely known format. Hence, they are unaffected, e.g.:works fine.
Over the Wand API, however, this yields incorrect results, see the attached test-set-sampling-factors. It uses
MagickSetSamplingFactors()
, which formats a 4:2:0 as4,2,0
, warps that into wrong sampling factors, then miscounts input data, and subsequently bails out with "unexpected end of file". Encoding JPEG also fails.Steps to Reproduce
Steps to Reproduce
Compile and run the attached test-set-sampling-factors.
Expected Behaviour
It should read the included 4:2:0 planar YUV image and store it into a JPEG file
Actual Behaviour
Images
No response
The text was updated successfully, but these errors were encountered: