GIMP Forums

Full Version: Script-fu script to conversion pdf to image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to gimp but I try to find a way how to convert multiple pdf files (they are in subfolders) to images (probably png or jpeg). I would like to keep resolution 400. For example the input filename could be like "london_map.pdf" and on the output should be "london_map.png". I found this script but would need somebody to help me with it because I do not understand script-fu much. If you would be so kind:

code here

I think that this scripts increases image number, but I don't know if it can take any name as input.


PS: Would it be possible to go through subfolders? I think it will take long time to convert, so do every folder separately seems not to be good idea.
Is it possible to run ghostscript or imagemagick on windows to do it?
What file should I download for Windows XP and gimp 2.4?
I found tool called "pdf ghostscript tool" maybe it can do the job. I will test it if I will found the executable.
(Feb 3, 2012 13:42)ofnuts Wrote: [ -> ]In there:

either the w32 or W64 , depending on your version of Windows.

Well, thanks. I have installed and set GS to system globals. What should I do now? I run the gswin32c.exe
but don't know to work with this. Can you tell me how to convert the pdf to png (or jpeg with specified quality)? I have my images in some directory so I would need to specify it and use loop to obtain subdirectories (optional) or just pdf files.

I am going to try the PDF Ghostscript tool and it need this program, but I cannot find the f*cking download link on Softpadia:
can you help me to find the link?
Yeah, I have seen the link. I told you I have installed GS and add it to globals. But what should I do now? I don't know how to write the commands to console.

I must download the program to print the pdf because it is neccessary to setup the program pdf gohost tool. But I cannot to get the download link. Maybe I am blind, but they have there so many confusing links leading on undesired location that I am lost on the softpadia.
I'm with Ofnuts, maybe a gimp script is not the way to go.

Using ImageMagic in windows you can recurse through a set of folders reasonably easily.
Obviously keep some sort of order to the folder you start in, have all your pdf's under it.
the command line is
for /r %x in (*.pdf) do mogrify -format png "%x"

and a screenshot

one advantage is it keeps the devolved images in the same folder as the pdf(s)

If you want a GUI then try XNviewMP (or maybe the older Xnview) f=60&t=24056&sid=a00842d4d914d152bd2982160432839c
( if that breaks use )

This screen shot is in linux but there is a Win version.

For both of these ghostscript will be a requirement.
Quality, you will have to try and see, the IM png's were about 10% larger than the XNview images, but better, difficult to say.
OK thanks for link. I found the program is for conversion from poscript to pdf If i understood it. So I will not use it.

In Dos command line, there is way to run loop but all command would be performed at once and that would not be good. All tasks would run at the same moment.

OK, so I am going to try the IM.

Well, I opened console in the main directory with maps and typed your command. Now I wait till it will finish. It is wonderful that is works. Looks it is not much memory consuming. But do you know what? It has low resolution. I need resolution 400 not 72. I try the -resample 400. But still the quality is not good enough (text in image is blured). What is the default quality of this command? My pdf has 6.5MB, png has 31 MB 13228 x 9356px. Too big in size. I used to have 20000 x 6000 images that have about 14-16MB in JPEG format. Is it possible to get better quality? Maybe I should use JPEG format. I try to reach quality that in Photoshop would be quality level 4 or 5 and that results to max 14-16MB.

Here I have uploaded image to show you differences in quality:

[Image: testquality.jpg?noCache=1328377802]

All images are very close detail.
The 1st is image that is in my folder, low JPEG quality.
The 3rd is image that I saved in Photoshop, and that was very big image (I guess 15000-20000 on the x axis).
So you can see that even the worst JPEG quality can produce better quality then the PNG file generated by morgify.
I have just tried the convert in IM, to convert JPEG and the quality is same:
for /r %x in (*.pdf) do convert -resample 400 -quality 100% "%x" "%x.jpg"

Although I will now use IM because it can not detail in high quality, I am interested if would it be possible to Disable some layer of the pdf file before conversion. I found that the map I conver to image has more layers and it would be interesting to have more variations of the map.

I read about that problem, that IM get less quality results than GS before, but wanted to see it.

So now, I would like to try the Ghostscript is anybody knows how to make loops in Ghostcro├║t console please help me.
Well It works! I don't use -resample, but -density instead and the quality is very high.

Also why I get such wide margin all around the document? It is really wide. The PDF does not have margin. In the JPEG it would cost much of filesize. I guess the margin is 30% of the width and 30% of the height. Is it possible to reduce the space?

And in case that there would be more pages to send to files how to do it?

I look for cropping of images and I found this wonderful topic, where all necessary examples of the conversion are presented:

Also I found, that png get much more better quality then jpeg, because it looks it is more intelligent in keeping pixel/color information then jpeg. But though Well compressed JPG at 400 resolution and quality from 34 to 40% gets still very good quality and less size. And what more! This compressed JPEG (big file) will be read much more faster by reader/viewer.

I will write it down here:
Image (not cropped!) 13228px x 9354px x32b
PNG size is 7.605 kb (I think it was 80% instead 100%) but decreasing quality has no sense because the files get bigger! Next PNG with quality cca 40% was 8MB. Loading of this image takes almost 5 seconds!

The same density and size in JPEG:
in 100% quality takes 5.554kB only.
In 34% (=4/12) quality takes 4.549kB only!
These images are read rapidly fast and take cca 1/3 of a second!

The command to crop margins I used was -shave 1600x1600 and
the resulting size is 4Mb. This is great.
I think you can visit for pdf to image converter for mac.Good luck to get the right guide.
Doremisoft PDF to Image Converter For Mac
I tried to do so but the ghostcript had refused to run with my version of GIMP alongside. I use this tool for such purposes actually, it doesn't do anything interesting but conversion to png yet it does with a low loss of quality. You might well use the pdf editing tool in order to do so
This forum has been DEAD for a long time and the spammers keep trying to take over.

Save yourself from them and go to instead
Reference URL's