views:

24

answers:

1

Hello all,

Just started using GIMP today. When I resize the canvas manually in GIMP (so that it's smaller than the image size) it lets me move the image around so that I can "change" the viewable area. How do I replicate this in a script? In other words, I want the script to pause at the canvas resizing step and let me position the image correctly.

The reason I'm asking: I've written a small script that will create square thumbnails of images. The way I'm doing this is by resizing the canvas so that the height and width are the same. If the height and width are different I change the higher of the two so that it is the same as the lower (e.g. 600x500 becomes 500x500). I then flatten the image and scale it to whatever 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'm using to resize the canvas is above. I know the last two values in the gimp-image-resize command refer to the offsets. This is what I want to manually modify when the script reaches this step. Any help would be greatly appreciated. Thanks!

+1  A: 

Does your code work? If so, here's a better-looking version of the same code:

(let ((smaller-edge (min width height)))
  (gimp-image-resize image smaller-edge smaller-edge 0 0))
Chris Jester-Young
It works, although your version definitely looks cleaner. Thanks! Being new to GIMP and Scheme, I didn't know a lot of the available methods. Unfortunately this still doesn't solve my problem.
ZDYN