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!
The InstaGuide to Changing Canvas Size in GIMP This method is so quick, that you can do it in only two steps! Step 1: Open the Image menu, and click Canvas Size. Step 2: Enter your chosen settings, and click Resize. That's all there is to it!
To Resize the Canvas by Dragging: In Edit mode, select the Resize Canvas tool from the Toolbar at the top of the panel. Position your cursor over the edge or corner of your image until it changes into a double-pointed arrow. Drag the canvas' border to the desired size.
Hold down the Command key while dragging a corner handle will scale the image proportionally. Choose the “Enter” key, or the Scale button in the dialog box to complete the change. The “M” key to selects the Move tool. Drag the adjusted image until it is positioned in the frame the way you want it to be.
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With