How to change GIMP print size with script-fu

474 views Asked by At

I am using GIMP 2.10.24. I have some image and I need to change Print Size Width to 21mm and Height to 30mm. I can do that with Set Image Print Resolution Dialog (Menu->Image->Print Size): screenshot

But there is my question: how could I do that using script-fu or python-fu?

1

There are 1 answers

3
xenoid On BEST ANSWER

Print size, size in pixels, and print definition are completely related:

print size = size in pixels รท print definition

So to change the image print definition you use

In Python:

pdb.gimp_image_set_resolution(image, xresolution, yresolution)

In Script-fu:

(gimp-image-set-resolution image xresolution yresolution)

In both case the X/Y resolutions are in dots per inch.

However if you are using Gimp just for this creating a Gimp script is overkill (the learning curve is quite steep). If the image is in a common format (JPEG, PNG, TIFF) the print definition is part of the image metadata (JPEG header, or EXIF data) and can be changed directly without decoding/reencoding the image using CLI utilities. For instance with ExifTool:

exiftool ${your_image} -xResolution=321 -yResolution=321