MagickWand API underdocumented

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
User avatar
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

MagickWand API underdocumented

Post by yecril71pl »

I find the MagickWand API insufficiently documented.
For example:

NewImageMagick: returns a wand required for all other methods in the API. +[Throws an exception upon failure. Use DestroyMagickWand to dispose. ]+

This is C API, we do not have implicit RAII here!
  1. Can the pair Genesis/Terminus be called multiple times?
  2. Are they idempotent?
  3. Must the calls be balanced?
  4. Are they reentrant?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickWand API underdocumented

Post by magick »

Can the pair Genesis/Terminus be called multiple times?
Yes.
Are they idempotent?
Yes.
Must the calls be balanced?
No, but recommended.
Are they reentrant?
Yes.

We added some more details to the NewMagickWand() methods. We expand the API documentation as time permits. Like many open-source projects we suffer from more work than volunteers.
User avatar
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

Re: MagickWand API underdocumented

Post by yecril71pl »

magick wrote:Like many open-source projects we suffer from more work than volunteers.
I have had to deal a lot with closed-source companies like Microsoft (I would give a hyperlink here but BBcode does not allow me to say rel="nofollow"); I would say your performance, your competence and your overall attitude is wonderful beyond comparison anyway.

Why do DestroyDrawingWand and DestroyPixelWand return pointers?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickWand API underdocumented

Post by anthony »

yecril71pl wrote:Why do DestroyDrawingWand and DestroyPixelWand return pointers?
So you can assign them back into the original Wand pointers. The value returned is just NULL.

Code: Select all

  wand=DestroyPixelWand(wand);
It makes the code a little more readable.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickWand API underdocumented

Post by magick »

It a secure programming technique. Always zero out pointers when you no longer use them. The Destroy*() methods simply return NULL.
User avatar
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

Re: MagickWand API underdocumented

Post by yecril71pl »

How do I interpret the value returned by MagickSetImageType?
Last edited by yecril71pl on 2011-05-02T08:45:42-07:00, edited 2 times in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickWand API underdocumented

Post by magick »

On success, MagickTrue is returned. If MagickFalse is returned, check image->exception for the reason MagickSetImageType() failed.
Post Reply