I have a bunch of screen shots and I'd like to crop out the window border. I would like to crop them all using a script.
I have access to the GIMP, but not photoshop so I assumed that the GIMP would be the best tool to use. I have not scripted with the GIMP before, so I looked up some GIMP crop scripts. The ones I found are all similar to what I want, but not quite. I thought it would be a simple matter to alter the script to what I need. But since I am not familiar with the scripting language it is proving more difficult than I thought. I found a great auto crop script here. Can someone help me customize it for what I need?
(define (script-fu-rs-center-crop filename outfilename width height)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(let* ((original-width (car (gimp-image-width image)))
(original-height (car (gimp-image-height image)))
(new-width original-width)
(new-height original-height)
(offset-x 0)
(offset-y 0))
(if (<= (/ original-width original-height) (/ width height))
(gimp-image-crop image original-width (* original-width (/ height width)) 0 (/ (- original-height (* original-width (/ height width))) 2) )
(gimp-image-crop image (* original-height (/ width height)) original-height (/ (- original-width (* original-height (/ width height))) 2) 0)
)
)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable outfilename outfilename)
(gimp-image-delete image)))
The overall dimensions are not the same for all the photos. But they do all have the same number of pixels on the top, left, right and bottom that I want to crop out. So let's say the image has pixel dimensions width
and height
and I want to remove t_junk
pixels off the top, b_junk
pixels off the bottom, l_junk
pixels off the left, and r_junk
pixels off the right. So I want the new image dimensions to be width - l_junk - r_junk
and height - t_junk - b_junk
.