Page 1 of 1

SuperSampling and AI

Posted: 2010-12-10T14:09:16-07:00
by NitroPye
I'm having a slight issue going from the command line or PHP to the C MagickWand API. I cannot get super sampling to work. Its probably in part due to my lack of fully grasping the concepts.

From the command line this works:

Code: Select all

convert -density 244 -resize 25% input.ai output.png
What would the C MagickWand code be? Currently I'm doing something like this

Code: Select all

MagickSetResolution(_wand, 244, 244);
MagickReadImage(_wand, "ai:/path/to/input.ai");
MagickAdaptiveResizeImage(_wand, _size.width, _size.height); // I feel like this is where I'm doing things wrong
MagickWriteImage(_wand, "/path/to/output.png");
Thanks in advance.

Re: SuperSampling and AI

Posted: 2010-12-10T15:25:05-07:00
by el_supremo
You don't explain what is going wrong but I'd suggest that you need code something like this:

Code: Select all

MagickAdaptiveResizeImage(_wand, MagickGetImageWidth(_wand)/4,MagickGetImageHeight(_wand)/4);
Pete

Re: SuperSampling and AI

Posted: 2010-12-10T16:15:57-07:00
by NitroPye
Thanks el_supremo.

The code essentially does what I'm doing already. I should have pointed out that _size is a struct containing the images original size.

The problem I am having is that the resulting image at the size I want ends up all jagged where as running from the command line using convert I end up with a nice smooth supersampled image.

Re: SuperSampling and AI

Posted: 2010-12-10T20:20:12-07:00
by el_supremo
The convert command doesn't use adaptive resize for the -resize option. It uses ResizeImage which you can access through MagickResizeImage.
Try this statement:

Code: Select all

MagickResizeImage(_wand, _size.width, _size.height,LanczosFilter,1.0);
Pete

Re: SuperSampling and AI

Posted: 2010-12-13T10:59:07-07:00
by NitroPye
Thanks, that worked a charm. I guess I should read up on my image scaling algos.