You are here

Script code for image size?

i want script code for
if image height>width
then height=300 and width is related to height size
else
width=300 and height is related to width size
(here image size is like 300 x (less than 300) or (less than 300 X 300))
now i want to create canvas 320 X 320 for that image with white background color
now the image size is 320 X 320 with white canvas background color
my gimp version 2.8 and i need script-Fu code

Script code for image size?

(let* ((width (car (gimp-drawable-width layer)))
       (height (car (gimp-drawable-height layer)))
       (aspect (/ height width)) ) 
  (if (< (/ 300 width) (/ 300 height))
      (gimp-layer-scale layer
                        300
                        (* 300 aspect) 
                        TRUE)
      (gimp-layer-scale layer 
                        (/ 300 aspect)
                        300 
                        TRUE )))

For the second part:

(gimp-context-set-background '(255 255 255))
(gimp-layer-resize layer 
                   320 
                   320 
                   (/ (- 320 (car (gimp-drawable-width layer))) 2) 
                   (/ (- 320 (car (gimp-drawable-height layer))) 2))
(gimp-layer-flatten layer)
Subscribe to Comments for "Script code for image size?"