How to implement the following code using MagickCore?

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
sunng1

How to implement the following code using MagickCore?

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

Re: How to implement the following code using MagickCore?

Post 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;
          }
sunng1

Re: How to implement the following code using MagickCore?

Post by sunng1 »

thank you very much, so I can learn more detail about command line!

thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to implement the following code using MagickCore?

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply