Post Reply 

Script-fu script to conversion pdf to image

Feb 2, 2012, 21:47 (This post was last modified: Feb 2, 2012 21:49 by 4ever.)
Post: #1
Script-fu script to conversion pdf to image
Hello,
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.

Thanks

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.
Find all posts by this user
Quote this message in a reply
Feb 2, 2012, 22:31
Post: #2
RE: Script-fu script to conversion pdf to image
Gimp is the wrong tool for this, check ImageMagick (in particular the "convert" utility). Both Gimp and ImageMagick use GhostScript to read in PDF, as far as I know.

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 3, 2012, 09:37
Post: #3
RE: Script-fu script to conversion pdf to image
Is it possible to run ghostscript or imagemagick on windows to do it?
Find all posts by this user
Quote this message in a reply
Feb 3, 2012, 09:44
Post: #4
RE: Script-fu script to conversion pdf to image
Yes, there is a Windows version of each. If you can already load PDFs in Gimp, you should have Ghostscript already. If not, read this:

http://registry.gimp.org/node/1616

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 3, 2012, 12:00 (This post was last modified: Feb 3, 2012 12:01 by 4ever.)
Post: #5
RE: Script-fu script to conversion pdf to image
What file should I download for Windows XP and gimp 2.4?
http://sourceforge.net/projects/ghostscript/files/
I found tool called "pdf ghostscript tool" maybe it can do the job. I will test it if I will found the executable.
Find all posts by this user
Quote this message in a reply
Feb 3, 2012, 13:42
Post: #6
RE: Script-fu script to conversion pdf to image
In there:
http://sourceforge.net/projects/ghostscr...ript/9.04/

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

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 3, 2012, 19:15 (This post was last modified: Feb 3, 2012 19:31 by 4ever.)
Post: #7
RE: Script-fu script to conversion pdf to image
(Feb 3, 2012 13:42)ofnuts Wrote:  In there:
http://sourceforge.net/projects/ghostscr...ript/9.04/

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:
http://www.softpedia.com/progDownload/Re...37363.html
can you help me to find the link?
Find all posts by this user
Quote this message in a reply
Feb 3, 2012, 22:01
Post: #8
RE: Script-fu script to conversion pdf to image
(Feb 3, 2012 19:15)4ever Wrote:  
(Feb 3, 2012 13:42)ofnuts Wrote:  In there:
http://sourceforge.net/projects/ghostscr...ript/9.04/

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:
http://www.softpedia.com/progDownload/Re...37363.html
can you help me to find the link?
Only if you want to use GS as a PDF printer.

Seen this? http://www.werockyourweb.com/install-gho...s-and-gimp

But as I told you above, the real winner isn't to use Gimp+GhostScript, but ImageMagick+GhostScript (ImageMagick is otherwise very easy to install).

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 11:31 (This post was last modified: Feb 4, 2012 11:34 by 4ever.)
Post: #9
RE: Script-fu script to conversion pdf to image
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.
Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 13:12
Post: #10
RE: Script-fu script to conversion pdf to image
Get it elsewhere: http://pages.cs.wisc.edu/~ghost/redmon/

If you don't know how to use a command line, then your chances at updating a script-fu to do something useful where really slim.

Finding how to call IM convert to do what you want is going to be easier, but if I can help you with the parameters to convert I won't help you with the .BAT to run the whole thing on all your files because I use Linux and have no Windows system with Gimp and GhostScript installed. But once you have the convert parameters OK, the problem ceases to be a graphics problems and becomes a mere Windows system problem, and you'll find thousands of forums for that.

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 14:37
Post: #11
RE: Script-fu script to conversion pdf to image
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 http://i.imgur.com/f7o67.jpg

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)
http://newsgroup.xnview.com/viewtopic.php f=60&t=24056&sid=a00842d4d914d152bd2982160432839c
( if that breaks use http://tinyurl.com/7x7n4cn )

This screen shot is in linux but there is a Win version. http://i.imgur.com/jrP5m.jpg

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.
Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 16:26 (This post was last modified: Feb 4, 2012 17:55 by 4ever.)
Post: #12
RE: Script-fu script to conversion pdf to image
@ofnuts:
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.

@rich2005:
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]
ENLARGE: http://postimage.org/image/46kh7afjn/

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.
Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 19:17 (This post was last modified: Feb 4, 2012 19:18 by 4ever.)
Post: #13
RE: Script-fu script to conversion pdf to image
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.
Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 20:04
Post: #14
RE: Script-fu script to conversion pdf to image
It looks like the right option for the quality/sharpness of the converted image in this case is -density. By default it is 72DPI which is the definition of CRT display. Modern LCD displatys are at 100-120 and print requires around 300.

[Image: 2Tvo0.png]

Visit this user's website Find all posts by this user
Quote this message in a reply
Feb 4, 2012, 20:36 (This post was last modified: Feb 4, 2012 20:57 by 4ever.)
Post: #15
RE: Script-fu script to conversion pdf to image
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?

Thanks
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Want to create the logos using script-fu and PHP dabhadepravin 1 51 Apr 14, 2014 08:29
Last Post: ofnuts
  CMYK Conversion crzycowboy 13 1,470 Apr 10, 2014 11:27
Last Post: rich2005
  GIMP batch process script run-time error Paddy Landau 4 113 Apr 8, 2014 22:42
Last Post: ofnuts
  [SOLVED] How to apply filters and input levels with script fu? tahi.laci 2 137 Apr 4, 2014 15:14
Last Post: tahi.laci
  resize and add layer script bulevardi 8 214 Apr 2, 2014 06:01
Last Post: paynekj

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS