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
togo

cloneImage problem

Post by togo »

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
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: cloneImage problem

Post by magick »

We cannot reproduce the problem you posted. We tried your code snippet with ImageMagick 6.3.6-3, the current release, and the image depth after it was cloned remained at 8 as expected.
togo

Re: cloneImage problem

Post by togo »

i read the ImageMagick-6.3.3 code, and find it is casted by the function ModifyCache() in cache.c
with the line "image->depth=QuantumDepth;"
and it is modifed in ImageMagick 6.3.6-3, also i tested with 6.3.6, it's ok now

thanks very much

btw, if i still use ImageMagick-6.3.3, and just add a new line like "resize_image->depth = image->depth;" after cloneimage,
is it ok?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: cloneImage problem

Post by anthony »

Resize creates a new image with new colors as such the default depth of theimage for writing out to a file is reset to the in memory quality.

Try setting -depth is you want it force the output image to be a specific depth.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply