Skip to content

Commit

Permalink
https://github.com/ImageMagick/ImageMagick/issues/4059
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Sep 6, 2021
1 parent a3d7d3f commit 9d97e95
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2021-09-06 6.9.12-22 <quetzlzacatenango@image...>
* Release ImageMagick version 6.9.12-21 GIT revision 16...

2021-09-06 6.9.12-22 <quetzlzacatenango@image...>
* prevent color reduction merging into one color (reference
https://github.com/ImageMagick/ImageMagick/issues/4059).

2021-09-04 6.9.12-21 <quetzlzacatenango@image...>
* Release ImageMagick version 6.9.12-21 GIT revision 16778:e0967eae2:20210904

Expand Down
3 changes: 1 addition & 2 deletions magick/attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1578,10 +1578,9 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type)
(void) NormalizeImage(image);
quantize_info=AcquireQuantizeInfo(image_info);
quantize_info->number_colors=2;
quantize_info->dither_method=FloydSteinbergDitherMethod;
quantize_info->colorspace=GRAYColorspace;
status=QuantizeImage(quantize_info,image);
quantize_info=DestroyQuantizeInfo(quantize_info);
status=MinMaxStretchImage(image,0.0,0.0,1.0);
image->matte=MagickFalse;
break;
}
Expand Down
28 changes: 15 additions & 13 deletions magick/quantize.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,7 @@ static MagickBooleanType AssignImageColors(Image *image,CubeInfo *cube_info)
if (cube_info->quantize_info->measure_error != MagickFalse)
(void) GetImageQuantizeError(image);
if ((cube_info->quantize_info->number_colors == 2) &&
((cube_info->quantize_info->colorspace == LinearGRAYColorspace) ||
(cube_info->quantize_info->colorspace == GRAYColorspace)))
(IsGrayColorspace(cube_info->quantize_info->colorspace)))
{
double
intensity;
Expand Down Expand Up @@ -2484,17 +2483,20 @@ static void PruneChild(CubeInfo *cube_info,const NodeInfo *node_info)
for (i=0; i < (ssize_t) number_children; i++)
if (node_info->child[i] != (NodeInfo *) NULL)
PruneChild(cube_info,node_info->child[i]);
/*
Merge color statistics into parent.
*/
parent=node_info->parent;
parent->number_unique+=node_info->number_unique;
parent->total_color.red+=node_info->total_color.red;
parent->total_color.green+=node_info->total_color.green;
parent->total_color.blue+=node_info->total_color.blue;
parent->total_color.opacity+=node_info->total_color.opacity;
parent->child[node_info->id]=(NodeInfo *) NULL;
cube_info->nodes--;
if (cube_info->nodes > cube_info->maximum_colors)
{
/*
Merge color statistics into parent.
*/
parent=node_info->parent;
parent->number_unique+=node_info->number_unique;
parent->total_color.red+=node_info->total_color.red;
parent->total_color.green+=node_info->total_color.green;
parent->total_color.blue+=node_info->total_color.blue;
parent->total_color.opacity+=node_info->total_color.opacity;
parent->child[node_info->id]=(NodeInfo *) NULL;
cube_info->nodes--;
}
}

/*
Expand Down

0 comments on commit 9d97e95

Please sign in to comment.