You are here

Resizing and Saving

Hello!

I'm not sure if this is the right place to be posting this question (sorry for being a total newb), but I was wondering if anyone could help with a very simple script for GIMP. After editing an image, I would like to be able to run a script that will do the following (in order):

1. Save a copy to a folder
2. Resize the image
3. Save a copy of the resized image to a different folder
4. Close the image

Seems simple enough, but without any background in scripting, I've been having a hard time. I've got the resizing part down. Here's what I've come up with:

(define (photoblog-resize-horizontal image drawable)
(let* ((cur-width (car (gimp-image-width image)))
(cur-height (car (gimp-image-height image)))
(height (/ (* cur-height 800) cur-width))
)
(gimp-image-scale image 800 height)
)
)
(script-fu-register "photoblog-resize-horizontal"
_"Resize Horizontal"
_"Resizes horizontal images for photoblog."
"Andre Mount"
"Andre Mount"
"December 4, 2010"
"*"
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
)
(script-fu-menu-register "photoblog-resize-horizontal"
"/Photoblog")

What I can't seem to figure out, however, is how to save copies of the open image. I've tried using "gimp-file-save" like this:

(gimp-file-save RUN-NONINTERACTIVE image drawable filename raw-filename)

...but I don't know what to use for the filename arguments. (I saw "file-jpeg-save" too, but that looks exceedingly complicated.)

Would anyone care to help? Or at least direct me to a better place to ask my question? Thanks!

Forums: 

It took me a while to figure it out (like I said, total newb), but here's what I came up with in case anyone's interested:

(define (photoblog-resize-horizontal image drawable)
(let* ((cur-width (car (gimp-image-width image)))
(cur-height (car (gimp-image-height image)))
(height (/ (* cur-height 850) cur-width))
(fullsize-filename (string-append "/home/amount/Desktop/Temp Pictures/Resized for Photoblog/Archive/" (car (gimp-image-get-name image))))
(resized-filename (string-append "/home/amount/Desktop/Temp Pictures/Resized for Photoblog/" (car (gimp-image-get-name image))))
)
(gimp-file-save RUN-NONINTERACTIVE image drawable fullsize-filename fullsize-filename)
(gimp-image-scale image 850 height)
(gimp-file-save RUN-NONINTERACTIVE image drawable resized-filename resized-filename)
)
)
(script-fu-register "photoblog-resize-horizontal"
_"Resize Horizontal"
_"Resizes horizontal images for photoblog."
"Andre Mount"
"Andre Mount"
"December 4, 2010"
"*"
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
)
(script-fu-menu-register "photoblog-resize-horizontal" "/Photoblog")

Subscribe to Comments for "Resizing and Saving"