About API description!!

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
diuming
Posts: 22
Joined: 2011-01-16T22:07:22-07:00
Authentication code: 8675308

About API description!!

Post by diuming »

About API description??
Last edited by diuming on 2011-01-19T22:46:13-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: About API description!!

Post by anthony »

API just means "Application Programming Interface"

So the question becomes... What API are you refering to?

All the API's are listed on the offical website, though many just refer to another API for the function list.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
diuming
Posts: 22
Joined: 2011-01-16T22:07:22-07:00
Authentication code: 8675308

Re: About API description!!

Post by diuming »

Dear Master,

I know that about API.

I encountered a big problem When I using MagickCore and MagickWand's C API.
Sometimes I do not understand function and argument's descriptions (It's not clear), So I have to post a question again again again and again!!

For example, I try to compose 4 channel image (c.jpg, m.jpg, y.jpg, k.jpg) into signal file (result_cmyk.jpg), But I still not success.

.
.
MagickWand * srcImageC, * srcImageM, * srcImageY, * srcImageK, * destImage;

MagickWandGenesis();

/*
* Create the winds
*/
srcImageC = NewMagickWand();
srcImageM = NewMagickWand();
srcImageY = NewMagickWand();
srcImageK = NewMagickWand();
destImage = NewMagickWand();

MagickReadImage(srcImageC, "c.jpg");
MagickReadImage(srcImageM, "m.jpg");
MagickReadImage(srcImageY, "y.jpg");
MagickReadImage(srcImageK, "k.jpg");


MagickSetSizeOffset(destImage, columns, rows, 0);
MagickSetSize(destImage, columns, rows);
MagickSetColorspace(destImage, CMYKColorspace); // The result image file always RGB
MagickSetImageResolution(destImage, 360, 360);
MagickSetImageUnits(destImage, PixelsPerInchResolution);

MagickBooleanType status;
status = MagickCompositeImageChannel(destImage, CyanChannel , srcImageC, CopyOpacityCompositeOp , 0, 0); //false
status = MagickCompositeImageChannel(destImage, MagentaChannel , srcImageM, CopyOpacityCompositeOp , 0, 0); //false
status = MagickCompositeImageChannel(destImage, YellowChannel , srcImageY, CopyOpacityCompositeOp , 0, 0); //false
status = MagickCompositeImageChannel(destImage, BlackChannel , srcImageK, CopyOpacityCompositeOp , 0, 0); //false
//I try to use combine, but still false

NSLog(@"Status : %i", status); // always get MagickFalse
if (status == MagickFalse)
ThrowWandException(destImage);

MagickWriteImage(destImage, "result_cmyk.jpg"); ///No image output

/*
* tidy up
*/
if (srcImageC) srcImageC = DestroyMagickWand(srcImageC);
if (srcImageM) srcImageM = DestroyMagickWand(srcImageM);
if (srcImageY) srcImageY = DestroyMagickWand(srcImageY);
if (srcImageK) srcImageK = DestroyMagickWand(srcImageK);
if (destImage) destImage = DestroyMagickWand(destImage);

MagickWandTerminus();
.
.

Sorry about that, Maybe my composite concept is incorrect.

Thanks for ImageMagick provides useful image processing tool.
Thanks alot.

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

Re: About API description!!

Post by anthony »

diuming wrote:For example, I try to compose 4 channel image (c.jpg, m.jpg, y.jpg, k.jpg) into signal file (result_cmyk.jpg), But I still not success.
You can NOT store multiple files into a JPG file. The File format simply does not allow for it!
As such it will automatically save the image into seperate files with a number which starts with zero.

See IM Examples, File Handling, Writing a Multi-Image Sequence - Adjoin Techniques
http://www.imagemagick.org/Usage/files/#adjoin

However it appears by the code you are not wanting that, but want ot combine the images.

Lokking in the source for "wand/mogrify.c" (for command line API) I find that "combine" option calles the MagickCore library function

Code: Select all

image = CombineImages(*images,channel,exception)
A search for header "*.h" files in magick source sub-directory I find this function in "magick/image.h"
as such the function is defined in "magick/image.c"

Its documentation can thus be found in the MagickCore "Image Methods"
http://www.imagemagick.org/api/image.php#CombineImages

However creating a CMYK image (or any other non-RGB colorspace image) from RGB greyscale images requires you to first set the greyscale images to the right colorspace (the "image->type" structure element in the "Image" structure, just as you would when performing the same operation from the command line API.

That is as shown in -- Combining non-RGB image channels
http://www.imagemagick.org/Usage/channe ... bine_other

The exact code I can not give you, without doing EVERYTHING. But the method and order is the same as for the command line API, and the coding sequence is clear.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
diuming
Posts: 22
Joined: 2011-01-16T22:07:22-07:00
Authentication code: 8675308

Re: About API description!!

Post by diuming »

I got it. thanks!

Diuming
Post Reply