Page 1 of 1

duplicate methods ?

Posted: 2009-10-07T04:01:48-07:00
by Xandros
Hello

i'd like to know if there are subtle differences between, for example, MagickSetImageCompression and MagickSetCompression ?

There are a few other couples of methods which according to the documentation appear to be doing 100% the same thing. Is that true ?

Which one is better to use in order to avoid future deprecation ?

thanks !

Re: duplicate methods ?

Posted: 2009-10-07T05:44:09-07:00
by magick
MagickSetCompression() is to set the compression before an image is created and MagickSetImageCompression() is to set the compression after an image is created. If you call MagickSetCompression() before an image is created, it is inherited when the image is created. If you call MagickSetImageCompression() after an image is created, it sets the compression attribute of the image.

Re: duplicate methods ?

Posted: 2009-10-07T09:32:47-07:00
by Xandros
ok thanks, as this subtile difference is not documented, it's valuable to know it !

so, as I understand it now, MagickSetCompression is only necessary when creating images from blank canvas, and is never needed if for example only converting between different file types.

The order would then be : read image, resize/transform, use MagickSetImageCompression to choose destination compression, write image to file.

is all that right ?

P.S. A little additional question regarding the ability to reduce memory consumption when reading image from file. on the command line, one uses

convert source.jpg[200x200] -resize "200x200" dest.jpg

How to achieve the same optimization with MagickWand functions please ? the read/resize/write functions are obvious, but the red text part ?... Specify the [200x200] directly inside the "filename" parameter of the MagickReadImage function ?

Thanks !

Re: duplicate methods ?

Posted: 2009-10-07T09:45:14-07:00
by magick
Just use it within the filename as you suggested. A filename appended with a geometry within brackets is an inline resize. You may instead be looking for the size hint which in modern versions of ImageMagick is set with jpeg:size (e.g. convert -debug jpeg:size 200x200...).

Re: duplicate methods ?

Posted: 2009-10-07T10:33:35-07:00
by Xandros
OK, didn't know about the jpeg:size thing, where can I find more details ? is it working for other file types ?

I read on the "usage" sample pages that it reduces memory consumption to append the geometry in brackets when creating thumbnails, so the -resize doesn't have much to do afterwards...

Re: duplicate methods ?

Posted: 2009-10-07T10:59:11-07:00
by magick
The size hint only works with JPEG. Inline cropping (e.g. image.jpg[200x200+10+20]) and resizing (e.g. image.jpg[100x100]) can save some memory but are most beneficial for wildcards (e.g. *.jpg[200x200]). In general, 'image.png[100x100]' is the same as 'image.png -resize 100x100'.

Re: duplicate methods ?

Posted: 2009-10-07T11:22:26-07:00
by Xandros
oh ok, it's -define jpeg:size=... i see ! is there an magickwand equivalent for this ? MagickImageSetProperty('jpeg:size', '..') ?

Re: duplicate methods ?

Posted: 2009-10-07T11:31:56-07:00
by magick
Right.

Re: duplicate methods ?

Posted: 2009-10-07T11:39:28-07:00
by Xandros
Great ! Thanks for all the help !

Re: duplicate methods ?

Posted: 2009-10-08T03:10:55-07:00
by Xandros
Hello
me again ..


MagickResetIterator and MagickSetFirstIterator do both set the iterator to the first image, arent those duplicate ? :)

Re: duplicate methods ?

Posted: 2009-10-08T04:33:55-07:00
by magick
No, the methods behave differently. Reset means give me the 1st image in the container when MagickNextImage() is called whereas MagickSetFirstIterator() causes MagickNextImage() to return the second image in the container.

Re: duplicate methods ?

Posted: 2009-10-08T04:46:58-07:00
by Xandros
Mm, strange ... Maybe I missed something ?...

Code: Select all

WandExport void MagickSetFirstIterator(MagickWand *wand)
{
  assert(wand != (MagickWand *) NULL);
  assert(wand->signature == WandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
  wand->active=MagickTrue;
  wand->pend=MagickFalse;
  wand->images=GetFirstImageInList(wand->images);
}


WandExport void MagickResetIterator(MagickWand *wand)
{
  assert(wand != (MagickWand *) NULL);
  assert(wand->signature == WandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
  wand->active=MagickFalse;
  wand->pend=MagickTrue;
  wand->images=GetFirstImageInList(wand->images);
}

Re: duplicate methods ?

Posted: 2009-10-08T05:36:35-07:00
by magick
Notice the active and pend members have different values?

Re: duplicate methods ?

Posted: 2009-10-08T09:31:51-07:00
by Xandros
hmm, nope :) well actually I do now :) have read too much code lately I guess :) sorry