load a PDF without antialiasing

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
19xxandrea
Posts: 4
Joined: 2016-07-22T04:58:24-07:00
Authentication code: 1151

load a PDF without antialiasing

Post by 19xxandrea »

Hi,

I need convert a PDF into an image for my app developed in C++.
I have no trouble to convert the PDF into the image but I need also to turn-off the antialias.

It is possible?

Here my simple code:

int main( int argc, char ** argv)
{
InitializeMagick(*argv);

Image * img = new Image();

img->density("100");
img->strokeAntiAlias(false); //This is wrong! It doesn't work!
img->read("input.pdf");
img->write("output.bmp");

return 0;
}

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: load a PDF without antialiasing

Post by snibgo »

IM delegates the rasterising of PDFs to Ghostscript. "-verbose" shows it gives the same command to GS regardless of the antialias setting.

I don't know if GS has an option for turning off anti-aliasing. If it does, you could ask for that feature to be added to IM, and for a workaround you could change delegates.xml.
snibgo's IM pages: im.snibgo.com
19xxandrea
Posts: 4
Joined: 2016-07-22T04:58:24-07:00
Authentication code: 1151

Re: load a PDF without antialiasing

Post by 19xxandrea »

Probably GS has the option that I need. Because if I run:

convert -density 100 -background white -flatten +antialias input.pdf output.bmp

it works fine. Exactly what I need.

But I can't reproduce this in my c++ code.

Thanks
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: load a PDF without antialiasing

Post by snibgo »

Oh, good. Why are you using strokeAntiAlias? The doc http://www.imagemagick.org/Magick++/Image++.html says this is for "drawing object outlines". For "antialiasing of rendered Postscript and Postscript or TrueType fonts", the doc says this is antiAlias.
snibgo's IM pages: im.snibgo.com
19xxandrea
Posts: 4
Joined: 2016-07-22T04:58:24-07:00
Authentication code: 1151

Re: load a PDF without antialiasing

Post by 19xxandrea »

also:

Code: Select all

img->antiAlias(false);
does't work in my case... :(
19xxandrea
Posts: 4
Joined: 2016-07-22T04:58:24-07:00
Authentication code: 1151

Re: load a PDF without antialiasing

Post by 19xxandrea »

Hi,

I have not yet found a solution. Could be my problem a small bug of the library?

Thanks
Post Reply