Page 1 of 1
How to implement the following code using MagickCore?
Posted: 2009-05-31T01:05:14-07:00
by sunng1
hi everyone:
I'm working for reducing the file size of GIF Image, and I found the following command line code :
Code: Select all
convert speed.gif \
\( -clone 0--1 -background none +append \
-quantize transparent -colors 63 -unique-colors \
-write mpr:cmap +delete \) \
-map mpr:cmap speed_cmap.gif
It force image to use one global colormap, so make GIF smaller,
My question is : how to implement this using MagickCore? or It's impossible?
thanks!!!
Re: How to implement the following code using MagickCore?
Posted: 2009-05-31T07:31:23-07:00
by magick
To translate a command line to the MagickCore API have a look at MogrifyImage() and MogrifyImageInfo() of the wand/mogrify.c source module. Each command line option calls MagickCore API methods from these modules. For example, -map is:
Code: Select all
if (LocaleCompare("map",option+1) == 0)
{
Image
*remap_image;
ImageInfo
*remap_info;
/*
Transform image colors to match this set of colors.
*/
(void) SyncImageSettings(image_info,*image);
if (*option == '+')
break;
remap_info=CloneImageInfo(image_info);
(void) CopyMagickString(remap_info->filename,argv[i+1],
MaxTextExtent);
remap_image=ReadImage(remap_info,exception);
remap_info=DestroyImageInfo(remap_info);
CatchException(exception);
if (remap_image == (Image *) NULL)
break;
(void) RemapImage(quantize_info,*image,remap_image);
InheritException(exception,&(*image)->exception);
remap_image=DestroyImage(remap_image);
break;
}
Re: How to implement the following code using MagickCore?
Posted: 2009-05-31T20:22:10-07:00
by sunng1
thank you very much, so I can learn more detail about command line!
thanks
Re: How to implement the following code using MagickCore?
Posted: 2009-06-02T20:54:10-07:00
by anthony
You can declare separate image structures, which you can't do from command lines, and this will let you replace the need for parenthesis.
That is you can clone a image into a separate Image list, for working, making it a lot easier.
The Library itself is a great guide on how to do things
Of course getting an initial program structure is something I find trickier. An example should be around somewhere however.