; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ; // ; // SCRIPT-FU PHOTOFORMAT ; // ; // Author : Gilles CAULIER [caulier.gilles@free.fr] ; // URL : http://caulier.gilles.free.fr ; // Script version : 1.0 ; // Langage : SCHEME (GIMP SCRIPT-FU) ; // Gimp version : 1.2.3 ; // License : GPL ; // ; // Version 1.1 by Raymond Ostertag 2004/09 ; // - ported to Gimp2 ; // - changed menu entry ; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ; Main script-fu fonction ; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// (define (script-fu-PhotoFormat inImage inLayer inPaperSize inCustomPaperSize inCustomWidth inCustomHeight inResolution) (set! FileName (car (gimp-image-get-filename inImage))) (set! inImageWidth (car (gimp-image-width inImage))) (set! inImageHeight (car (gimp-image-height inImage))) (if (> inImageWidth inImageHeight) (begin (set! inFormatImage 1) ; Horizontal format ) (begin (set! inFormatImage 0) ; Vertical format ) ) (if (= inCustomPaperSize TRUE) (begin ; Custom size (set! Width inCustomWidth) (set! Height inCustomHeight) ) (begin ; Standard size (if (= inPaperSize 0) ; 9x13 cm (begin (set! Width 9) (set! Height 13) ) ) (if (= inPaperSize 1) ; 10x15 cm (begin (set! Width 10) (set! Height 15) ) ) (if (= inPaperSize 2) ; 13x19 cm (begin (set! Width 13) (set! Height 19) ) ) (if (= inPaperSize 3) ; 15x21 cm (begin (set! Width 15) (set! Height 21) ) ) (if (= inPaperSize 4) ; 18x24 cm (begin (set! Width 18) (set! Height 24) ) ) (if (= inPaperSize 5) ; 20x30 cm (begin (set! Width 20) (set! Height 30) ) ) (if (= inPaperSize 6) ; 21x30 cm (begin (set! Width 21) (set! Height 30) ) ) (if (= inPaperSize 7) ; 30x40 cm (begin (set! Width 30) (set! Height 40) ) ) (if (= inPaperSize 8) ; 30x45 cm (begin (set! Width 30) (set! Height 45) ) ) (if (= inPaperSize 9) ; 40x50 cm (begin (set! Width 40) (set! Height 50) ) ) (if (= inPaperSize 10) ; 50x75 cm (begin (set! Width 50) (set! Height 75) ) ) ) ) ; Calculate the new size with the H/V format. (if (= inFormatImage 0) (begin ; Vertical format (set! NewImageWidth (* (/ Width 2.54) inResolution)) (set! NewImageHeight (* (/ Height 2.54) inResolution)) ) (begin ; Horizontal format (set! NewImageWidth (* (/ Height 2.54) inResolution)) (set! NewImageHeight (* (/ Width 2.54) inResolution)) ) ) (set! DuplicateinImage (car (gimp-image-duplicate inImage))) (gimp-image-flatten DuplicateinImage) (gimp-image-set-resolution DuplicateinImage inResolution inResolution) (if (= inFormatImage 0) (begin ; Vertical format (gimp-image-scale DuplicateinImage NewImageWidth (* (/ NewImageWidth inImageWidth) inImageHeight) 0 0) ) (begin ; Horizontal format (gimp-image-scale DuplicateinImage (* (/ NewImageHeight inImageHeight) inImageWidth) NewImageHeight 0 0) ) ) (set! TheNewImage (car (gimp-image-new NewImageWidth NewImageHeight RGB))) (gimp-image-add-layer TheNewImage (car (gimp-layer-new TheNewImage NewImageWidth NewImageHeight RGB-IMAGE "Background" 100 NORMAL-MODE)) 0) (gimp-drawable-fill (car (gimp-image-get-active-drawable TheNewImage)) 2) (gimp-image-set-resolution TheNewImage inResolution inResolution) (gimp-image-set-filename TheNewImage FileName) (gimp-display-new TheNewImage) (gimp-selection-all DuplicateinImage) (gimp-edit-copy (car (gimp-image-get-active-drawable DuplicateinImage))) (gimp-edit-paste (car (gimp-image-get-active-drawable TheNewImage)) TRUE) (gimp-image-flatten TheNewImage) ) ; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ; Record the filter into the GIMP ; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// (script-fu-register "script-fu-PhotoFormat" ; The main fonction. _"/Script-Fu/Photo/Print photographic format..." ; Gimp menu entry. "Prepare the image to the photographic paper size transfert" "Gilles CAULIER " "Gilles CAULIER " "2002/09/21" "RGB*" SF-IMAGE "Image" 0 ; An instance of the active image. SF-DRAWABLE "Layer" 0 ; An instance of the active layer. SF-OPTION _"Standard photographic paper size (cm)" '(_"9x13" _"10x15" _"13x19" _"15x21" _"18x24" _"20x30" _"21x30" _"30x40" _"30x45" _"40x50" _"50x75") SF-TOGGLE _"Use custom paper size" FALSE SF-ADJUSTMENT _"Custom paper width (cm)" '(10 1 1000 1 10 0 1) SF-ADJUSTMENT _"Custom paper height (cm)" '(15 1 1000 1 10 0 1) SF-ADJUSTMENT _"Print resolution (pixels/in)" '(300 150 9600 10 100 0 1) ; Size of the border line. )