GIMP - Canvas Resize Script

Just started using GIMP today. When I manually resize the canvas in GIMP (so that it is smaller than the image size), it allows me to move the image around so that I can "change" the visible area. How to reproduce this in a script? In other words, I want the script to stop at the resize step and allow me to position the image correctly.

The reason I ask: I wrote a small script that will create square thumbnails of images. The way I do this is to resize the canvas so that the height and width are the same. If the height and width are different, I change the top of them so that it is the same as the bottom (for example, 600x500 becomes 500x500). Then I align the image and scale it to what I need.

(if (>= width height)
    (begin
        (gimp-image-resize image height height 0 0)
    )
    (begin
        (gimp-image-resize image width width 0 0)
    )
)

The code I use to resize the canvas is above. I know that the last two values ​​in the gimp-image-resize command refer to offsets. This is what I want to change manually when the script reaches this step. Any help would be greatly appreciated. Thank!

+5
source share
1 answer

? , :

(let ((smaller-edge (min width height)))
  (gimp-image-resize image smaller-edge smaller-edge 0 0))
+3

All Articles