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 3, 2012, 09:37
Post: #2
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, 12:00 (This post was last modified: Feb 3, 2012 12:01 by 4ever.)
Post: #3
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, 19:15 (This post was last modified: Feb 3, 2012 19:31 by 4ever.)
Post: #4
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 4, 2012, 11:31 (This post was last modified: Feb 4, 2012 11:34 by 4ever.)
Post: #5
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, 14:37
Post: #6
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.

** https://www.gimp-forum.net/ now answering questions**
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: #7
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: #8
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:36 (This post was last modified: Feb 4, 2012 20:57 by 4ever.)
Post: #9
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
Feb 5, 2012, 00:30 (This post was last modified: Feb 5, 2012 11:37 by 4ever.)
Post: #10
RE: Script-fu script to conversion pdf to image
I look for cropping of images and I found this wonderful topic, where all necessary examples of the conversion are presented:
http://ubuntuforums.org/archive/index.php/t-391467.html

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!

Edit:
The command to crop margins I used was -shave 1600x1600 and
the resulting size is 4Mb. This is great.
Find all posts by this user
Quote this message in a reply
Feb 6, 2012, 06:22
Post: #11
RE: Script-fu script to conversion pdf to image
I think you can visit doremisoft.com for pdf to image converter for mac.Good luck to get the right guide.
Doremisoft PDF to Image Converter For Mac

I'm very glad to share my pdf tools for you.PDF to Word Converter For Mac
PDF to Epub Converter For Mac
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Any plugin for open multiple image in paint.net shinprog 1 405 Oct 31, 2017 11:38
Last Post: paynekj
  Scale image to specific size MattRothschild 1 275 Sep 15, 2017 11:13
Last Post: ythgilb
  Request for script chlebna 1 232 Sep 13, 2017 09:35
Last Post: ythgilb
  Request for script - Guillotine + Watermark sunslick 1 284 Sep 4, 2017 08:51
Last Post: ythgilb
  Script-fu: How to create new, addressable layer using gimp-floating-sel-to-layer Bertholomäus 1 325 Aug 31, 2017 14:32
Last Post: Bertholomäus

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS