i want script code
case 1:if image height>width then i want to fix height=300 and width is related to height size
case 2:if image width>height than i want to fix width=300 and height is related to width size
(it for image is more than 300 X 300 or less than 300 X 300, i mean to say if image height and width is less than 300 then we need to increase the size of image up to 300 it is either height or width as per above two cases, and if image size is more that 300 then we need to decrease the size up to 300 it is either height or width as for above two cases)
now i have image with size 300 X (Less than 300) or (Less than 300) X 300
i want to add canvas for that image with size 320 X 320 and black background color and that image should be in middle.
now i have image with size 320 X 320.
now i have Gimp 2.8 version and i need script -Fu code
i have some code please modify it once
(define (script-fu-sg-kumar-kovuru image layer)
(let* ((width (car (gimp-drawable-width layer)))
(height (car (gimp-drawable-height layer)))
(aspect (/ height width))
)
(gimp-image-undo-group-start image)
(gimp-context-push)
(if (< (/ 300 width) (/ 300 height))
(gimp-layer-scale layer
300
(* 300 aspect)
TRUE)
(gimp-layer-scale layer
(/ 300 aspect)
300
TRUE ))
(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)
; (gimp-image-resize-to-layers image) ; Uncomment if image should be scaled
(gimp-context-pop)
(gimp-image-undo-group-end image)
(gimp-displays-flush)
)
)
(script-fu-register "script-fu-sg-kumar-kovuru"
"Scale layer per Kumar Kovuru"
"Fit layer in 300x300 with white border"
"Saul Goode"
"Saul Goode"
"September 2013"
"RGB*,GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
)
(script-fu-menu-register "script-fu-sg-kumar-kovuru"
"<Image>/Filters/Misc/"
)
it is working but if image size is more than 300 X 300 then it is fixed size 300 X 300 and and getting canvas and rest of the size i mean to say i f image size is 420 X 380 it is converting 300 X 290 image and with canvas 320 X 320 but res t of the pixels means 320 to 420 X 320 to 380 getting white color
-------------------------------------------------------------------------------------------------
Thank you saulgoode
it is working Fine
Remove the semicolon at the start of the line containing "Uncomment if image should be scaled".
So the script I wrote does what you want except now you want the background to be black?
Recent comments