Skip to content

Commit

Permalink
Make MagickSet/GetSamplingFactors() use ':' instead of ','
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
janlinde committed Feb 2, 2022
1 parent 51f487a commit c506c6a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions MagickCore/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ MagickExport MagickStatusType ParseAffineGeometry(const char *geometry,
% relative to the values.
%
% Values may also be separated by commas, colons, or slashes, and offsets.
# Chroma subsampling definitions have to be in the form of a:b:c.
% Offsets may be prefixed by multiple signs to make offset string
% substitutions easier to handle from shell scripts.
% For example: "-10-10", "-+10-+10", or "+-10+-10" will generate negtive
Expand Down
2 changes: 1 addition & 1 deletion MagickCore/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ struct _ImageInfo
quality; /* compression quality */

char
*sampling_factor, /* JPEG write sampling factor */
*sampling_factor, /* Chroma subsampling ratio string */
*server_name, /* X windows server name - display/animate */
*font, /* DUP for draw_info */
*texture, /* montage/display background tile */
Expand Down
10 changes: 5 additions & 5 deletions MagickWand/magick-property.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,10 +1512,10 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
if (wand->image_info->sampling_factor == (char *) NULL)
return(sampling_factors);
i=0;
for (p=wand->image_info->sampling_factor; p != (char *) NULL; p=strchr(p,','))
for (p=wand->image_info->sampling_factor; p != (char *) NULL; p=strchr(p,':'))
{
while (((int) *p != 0) && ((isspace((int) ((unsigned char) *p)) != 0) ||
(*p == ',')))
(*p == ':')))
p++;
i++;
}
Expand All @@ -1525,10 +1525,10 @@ WandExport double *MagickGetSamplingFactors(MagickWand *wand,
ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed",
wand->image_info->filename);
i=0;
for (p=wand->image_info->sampling_factor; p != (char *) NULL; p=strchr(p,','))
for (p=wand->image_info->sampling_factor; p != (char *) NULL; p=strchr(p,':'))
{
while (((int) *p != 0) && ((isspace((int) ((unsigned char) *p)) != 0) ||
(*p == ',')))
(*p == ':')))
p++;
sampling_factors[i]=StringToDouble(p,(char **) NULL);
i++;
Expand Down Expand Up @@ -2793,7 +2793,7 @@ WandExport MagickBooleanType MagickSetSamplingFactors(MagickWand *wand,
return(MagickTrue);
for (i=0; i < (ssize_t) (number_factors-1); i++)
{
(void) FormatLocaleString(sampling_factor,MagickPathExtent,"%g,",
(void) FormatLocaleString(sampling_factor,MagickPathExtent,"%g:",
sampling_factors[i]);
(void) ConcatenateString(&wand->image_info->sampling_factor,
sampling_factor);
Expand Down
2 changes: 1 addition & 1 deletion coders/jp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ static MagickBooleanType WriteJP2Image(const ImageInfo *image_info,Image *image,
parameters->cp_disto_alloc=OPJ_TRUE;
}
if (image_info->sampling_factor != (const char *) NULL)
(void) sscanf(image_info->sampling_factor,"%d,%d",
(void) sscanf(image_info->sampling_factor,"%d:%d",
&parameters->subsampling_dx,&parameters->subsampling_dy);
property=GetImageProperty(image,"comment",exception);
if (property != (const char *) NULL)
Expand Down

0 comments on commit c506c6a

Please sign in to comment.