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.
sunng1
Post
by sunng1 » 2009-05-31T01:05:14-07:00
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!!!
magick
Site Admin
Posts: 11064 Joined: 2003-05-31T11:32:55-07:00
Post
by magick » 2009-05-31T07:31:23-07:00
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;
}
sunng1
Post
by sunng1 » 2009-05-31T20:22:10-07:00
thank you very much, so I can learn more detail about command line!
thanks
anthony
Posts: 8883 Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia
Post
by anthony » 2009-06-02T20:54:10-07:00
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.