question about cloneImage problem ?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
haloween
Posts: 2
Joined: 2019-03-18T21:01:38-07:00
Authentication code: 1152

question about cloneImage problem ?

Post by haloween »

i write a program to resize an image use resizeImage function,
however i found that, the depth value was changed after resizeImage function called,

then i read the source of the resize.c, find that, the depth was changed after the CloneImage()

like
1172 fprintf(fp, "----- image %u\n", image->depth);
1173
1174 resize_image=CloneImage(image,columns,rows,MagickTrue,exception);
1175
1176 fprintf(fp, "---image %u -- resize_image %u\n", image->depth, resize_image->depth );

the output is
----- image 8
---image 8 -- resize_image 16

is it a bug? or i had made something wrong.

btw, i use ImageMagick-6.3.3,

thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: question about cloneImage problem ?

Post by fmw42 »

When you resize your image, it creates new colors due to the resampling which blends pixels in a small neighborhood of the image. So if you create more than 256 colors, the image may go from palette 8-bit to truecolor 24-bit. This is not a bug. If you want to keep the same depth, then reset it after the resize.
Post Reply