Page 1 of 1
DirectClass vs. PseudoClass
Posted: 2010-07-25T01:22:15-07:00
by pilim
Hi Everybody,
I'm trying to resize GIF images and convert them to other formats such as JPEG.
I found that the process of resizing is failed when the image is PseudoClass (Can see that with the identify command).
I lack the knowledge of the difference DirectClass and PseudoClass, and what is storage class. Tried to google for information, but was unable to find what I was after, this issue looks very hard to trace.
Can you help me find proper documentation regarding the issue and storage class types, the difference between them, and any other related information that might help.
Also if you can direct me on the way to resize images between the storage classes, and the logic behind it.
Thanks in advance!
Re: DirectClass vs. PseudoClass
Posted: 2010-07-25T10:11:29-07:00
by Drarakel
pilim wrote:I found that the process of resizing is failed when the image is PseudoClass
That shouldn't happen. Can you post a link to your input file and specifiy the commandline and the IM version you used?
Re: DirectClass vs. PseudoClass
Posted: 2010-07-26T19:26:57-07:00
by anthony
As mentioned... Their should be no differences. If it is than either the library is broken, or more likely you own image processing module is broken.
Major operations involving image modifications would generally upgrade PsuedoColor images (images using a color table) to a DirectColor (images using separate color values for every pixel) before the operation is applied.
I myself hit that problem with my initial implementations -distort and -morphology, (image came out black or unchanged for GIF images) but it was fix by first converting the image from PsuedoColor to DirectColor.
This is generally done after making a 'Clone' of the input image, into which I can store the results as completely separate image to the originally given input image. here is the relevent code form 'DistortImage()' in "distort.c" in the core library.
Code: Select all
distort_image=CloneImage(image,geometry.width,geometry.height,MagickTrue,
exception);
if (distort_image == (Image *) NULL)
return((Image *) NULL);
/* if image is ColorMapped - change it to DirectClass */
if (SetImageStorageClass(distort_image,DirectClass) == MagickFalse)
{
InheritException(exception,&distort_image->exception);
distort_image=DestroyImage(distort_image);
return((Image *) NULL);
}
That is setting the storage class of my result image to a DirectColor Class (part colored) checking the result, so I can clean up and abort if it failed.
That is the key function call is...
Code: Select all
SetImageStorageClass(distort_image,DirectClass)
Note the actual reason for failure (the exception) is transferred form the distort image to the original input images 'exception' structure for reporting to the user.
Re: DirectClass vs. PseudoClass
Posted: 2010-07-27T02:47:09-07:00
by pilim
@ Drarakel & Anthony - Thanks for your replies!
@ Anthony - I can really see you put an effort digging the source code, so once again thank you for making the issue clearer for me. Is there any other documentation available in order to understand the insights you shared, other then reading the source code (which is a very good option, but takes much more time)?
The IM version I currently use is:
Code: Select all
$ identify -version
Version: ImageMagick 6.5.1-0 2009-08-27 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
I'll try to recreate the problem I experienced with this version.
Re: DirectClass vs. PseudoClass
Posted: 2010-07-27T19:32:31-07:00
by anthony
As I have only been coding Magick Core library, I can't comment too well on other API's.
Generally I grab an existing and reprogram it to suit.
For finiding a specific big of code I search "wand/mogrify.c" for the command line option (two places for each on a syntax check, the other the execution), and follow the librariy calls. looking for the functions by grepping header files. But then that is me. I am also trying to make more use of 'tags' to directly jump to the right place.