nsm
nsm

Reputation: 319

Edit image files with Gimp script-fu

I'm trying to edit a pdf file with 100 pages, all of them images I need to export as png, setting their image mode as greyscale, and setting also their resolution, width and heigth.

How can I write a scheme (or python) script that perform this actions so that i could apply them by gimp in batch mode?
I've searched in the internet but didn't find simpy stated instructions.

Upvotes: 1

Views: 762

Answers (1)

xenoid
xenoid

Reputation: 8904

ImageMagick's convert will do all this in one call in a command prompt:

convert -density 200 -colorspace Gray input.pdf -geometry 1000 ouput.png

will produce 1000px-wide grayscale PNGs (output-0 to output-(N-1).png) using a 200DPI rendering of the PDF.

You can also use Gimp scripting but you'll have a lot more to learn and AFAIK the API for the PDF loader only loads at 100DPI.

A slightly more manual method could be to:

  • Load (manually) the image in Gimp (you can specifiy the DPI in that case). This loads all the pages as layers.
  • Image>Mode>RGB to convert the image to grayscale.
  • Image>Scale image to set the size of all the pages
  • Save the individual layers to PNG (there are scripts for this, for instance this one)

Upvotes: 2

Related Questions