Gimp-Forum.net

Full Version: script-fu convert pdf to png WITHOUT antialiasing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am not familiar with script-fu and I really have the urgent need for a script that converts a PDF to a PNG without the anti-aliasing. (raw). I want to do this with the Gimp because of the perfect result but till this moment I am not able to write a script that does also set the anti-aliasing off. 

Please can somebody help me??? 

Thanks in advance!!!
You don't ned Gimp for this. ImageMagick will do it very quickly:

Code:
magick convert image-in.pdf -threshold 50% image-out.png

(in older versions of IM the command is just "convert").
I was looking at this last night and also came up with ImageMagick (IM)

Code:
convert -density 100 -background white -flatten +antialias input.pdf output.png

-density to set the size, 300 might be best
+antialias one of those strange IM switches where '+' turns it off.

Then some questions which arise from your post, in particular RAW output which in Gimp is .data
That does not work with IM, the output file.data defaults to pdf (without antialisaing) but a format such as PNM might be ok.


edit: read the post again and you want png, so that last bit is not needed, but what is meant by (raw)?

Looking at Gimp scripting procedures, opening a PDF does not seen to have any provision for turning anti-aliasing off or setting the ppi.
Maybe open the file, apply the threshold filter to remove anti-aliasing, export as png

Also depends on the PDF. Is it pure text or pure text with graphics or something else?
Hi,

I'm new and not very technical.  Like the OP, I want to convert pdf files to png (or any other graphic format).   I want the png to be the same size and resolution as the pdf.  I know how to make the conversion but am not getting the desired resolution.  Should I use ImageMagick or is there a simple way to do this in GIMP?

The pdf files contain sheet music, mostly black images on white.   I'm using the png files in order to fit two tunes to a page.

Thanks,
Marcia Lou
2.8
welcome to gimp-forum.net

Sorry but it becomes a bit technical

The problem is a PDF can contain both vector objects (maybe text, maybe graphics) which can scale to any size or an embedded 'picture' a bitmap which will be a specific original size in pixels.

If you can open your PDF in a PDF viewer, (sorry I do not have a windows one around) and check the properties you might find the designated paper size.

This example is A4: Just made it and the text (notation) is a vector. Most likely your music will be an embedded image.

[Image: g84PcRs.jpg]


Gimp is a bitmap editor, works in pixels, not vector.
Any vector is converted to a fixed size when you first open the PDF. Gimp will use the value 100 ppi unless you change it to higher resolution. This for example the A4 sheet at 300 ppi to give printing quality.

[Image: IN76GeD.jpg]

ImageMagick is no different, the -density 300 setting is the equivalent.

Of course if the PDF contains the notation as a low quality bitmap 'picture', and you say they are images (of unknown quality) then no amount of adjustment will improve it. In that case it is try-and-see but generally try 300 ppi to start with.

If you can share one of the sheets - dropbox or similar file-share - then it will be possible to give more specific advice.
(06-15-2018, 07:16 PM)Marcia Lou Wrote: [ -> ]Hi,

I'm new and not very technical.  Like the OP, I want to convert pdf files to png (or any other graphic format).   I want the png to be the same size and resolution as the pdf.  I know how to make the conversion but am not getting the desired resolution.  Should I use ImageMagick or is there a simple way to do this in GIMP?

The pdf files contain sheet music, mostly black images on white.   I'm using the png files in order to fit two tunes to a page.

Thanks,
Marcia Lou
2.8
Hi! I'd recommend you using this program to convert pdf to png. It doesn't require any extra software and works pretty fast and stable. I'm not very technical too and this tool seemed quite easy for me to use.
It is one of those 'free' online converters and some can be quite useful this one not so much.

Nothing is ever free. This from their terms, very common these days, data slurping, google, facebook....all the same.
When you access the Service, use the search function, convert files or download files, your IP address, country of origin and other non-personal information about your computer or device (such as web requests, browser type, browser language, referring URL, operating system and date and time of requests) may be recorded for log file information, aggregated traffic information

Hate those 'clever' (IMHO not-so-clever) links. It points to https://img-converter.com/en/convert/pdf-to-png/

Does what it says. Converts the pdf to png. Unfortunately your PDF that you need at 300 ppi gets 'down-graded' to 72 ppi. Much smaller than required.

Best use Gimp as indicated in previous posts.