RSS/Atom feed Twitter
Site is read-only, email is disabled

how to write a script to automate processing a multi-page PDF file?

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

5 of 5 messages available
Toggle history

Please log in to manage your subscriptions.

how to write a script to automate processing a multi-page PDF file? Daryna Baikadamova 02 Nov 08:47
  how to write a script to automate processing a multi-page PDF file? David Gowers 02 Nov 14:16
   how to write a script to automate processing a multi-page PDF file? Daryna Baikadamova 02 Nov 21:17
    how to write a script to automate processing a multi-page PDF file? Chris Mohler 02 Nov 22:06
  how to write a script to automate processing a multi-page PDF file? Sven Neumann 04 Nov 21:43
Daryna Baikadamova
2008-11-02 08:47:15 UTC (about 16 years ago)

how to write a script to automate processing a multi-page PDF file?

Hi!

I want to strip logo from every page of a PDF file and would like a script that:

- opens a file (say "foo.pdf", preferably allow me to specify source filename)
- specify convert each page to a image with 300dpi resolution - convert all images (all pages) from RGB (or whatever) to indexed 1-bit black and white
- save each image with foo_.tiff and specify "CCITT group 4 fax" as the compression algorithm

So that when the script finishes, all I have to do is to get rid of the logo by the eraser and click "save" again for each image.

Would it be possible to automate the task mentioned above? If so, would you please give a script which does this job? I am only a GIMP newbie and I am on a tight schedule.

Thanks!

Daryna

David Gowers
2008-11-02 14:16:54 UTC (about 16 years ago)

how to write a script to automate processing a multi-page PDF file?

Hi,

On Sun, Nov 2, 2008 at 6:17 PM, Daryna Baikadamova wrote:

Hi!

I want to strip logo from every page of a PDF file and would like a script that:

- opens a file (say "foo.pdf", preferably allow me to specify source filename)
- specify convert each page to a image with 300dpi resolution

GIMP currently does not allow you to specify resolution when non-interactively loading PDFs.

- convert all images (all pages) from RGB (or whatever) to indexed 1-bit black and white
- save each image with foo_.tiff and specify "CCITT group 4 fax" as the compression algorithm

So that when the script finishes, all I have to do is to get rid of the logo by the eraser and click "save" again for each image.

Would it be possible to automate the task mentioned above?

Yes, you could do this with a automation tool such as AutoIt (windows) or xdotool (Linux) and a bit of Python scripting. However, using ImageMagick instead (and not using GIMP at all for this task, except the final editing) in conjunction with Python scriptiing might be a less painful way to do this.

David

Daryna Baikadamova
2008-11-02 21:17:38 UTC (about 16 years ago)

how to write a script to automate processing a multi-page PDF file?

okay, so I use an automated tool (maybe ghostscript) to convert each page in a PDF file to tiff 300dpi 1-bit BW images named by their page number.

However in GIMP, are there ways to automatically open all tiff files in the directory at once? Then all I need to do for each image is to erase the logo, save and close the image.

On Mon, Nov 3, 2008 at 2:16 AM, David Gowers wrote:

Hi,

On Sun, Nov 2, 2008 at 6:17 PM, Daryna Baikadamova wrote:

Hi!

I want to strip logo from every page of a PDF file and would like a script that:

- opens a file (say "foo.pdf", preferably allow me to specify source filename)
- specify convert each page to a image with 300dpi resolution

GIMP currently does not allow you to specify resolution when non-interactively loading PDFs.

- convert all images (all pages) from RGB (or whatever) to indexed 1-bit black and white
- save each image with foo_.tiff and specify "CCITT group 4 fax" as the compression algorithm

So that when the script finishes, all I have to do is to get rid of the logo by the eraser and click "save" again for each image.

Would it be possible to automate the task mentioned above?

Yes, you could do this with a automation tool such as AutoIt (windows) or xdotool (Linux) and a bit of Python scripting. However, using ImageMagick instead (and not using GIMP at all for this task, except the final editing) in conjunction with Python scriptiing might be a less painful way to do this.

David

Chris Mohler
2008-11-02 22:06:13 UTC (about 16 years ago)

how to write a script to automate processing a multi-page PDF file?

On Mon, Nov 3, 2008 at 2:17 PM, Daryna Baikadamova wrote:

okay, so I use an automated tool (maybe ghostscript) to convert each page in a PDF file to tiff 300dpi 1-bit BW images named by their page number.

However in GIMP, are there ways to automatically open all tiff files in the directory at once? Then all I need to do for each image is to erase the logo, save and close the image.

It might be faster to use imagemagick - something like:

ls *.tif | xargs -l -i convert -fill white -draw 'rectangle 0,0,100,100' {} new_images/{}

You probably need to adjust the coordinates for the rectangle, and the above command assumes you are inside the directory with the TIFF files and you have created a new directory inside of it named "new_images". I'm using linux also - I'm pretty sure imagemagick runs on windows, but I have no experience with it...

HTH, Chris

Sven Neumann
2008-11-04 21:43:44 UTC (about 16 years ago)

how to write a script to automate processing a multi-page PDF file?

Hi,

On Sun, 2008-11-02 at 20:47 +1300, Daryna Baikadamova wrote:

- opens a file (say "foo.pdf", preferably allow me to specify source filename)
- specify convert each page to a image with 300dpi resolution - convert all images (all pages) from RGB (or whatever) to indexed 1-bit black and white
- save each image with foo_.tiff and specify "CCITT group 4 fax" as the compression algorithm

Why don't you just use the proper tools for the job? pdftoppm uses the same PDF rendering engine as the GIMP plug-in does and it is trivial to process the resulting PPM file to whatever format you need.

Sven