; polaroid.scm A Script-Fu script to turn a GIMP-image into a 'Polaroid' snap. ; The script can also recreate the yellow/red colour ; characteristics of a traditional polaroid snapshot. ; ; Copyright (C) 2003, Avi Bercovich ; ; version 0.4 ; TODO: ; - work on selections ; - stacking ; - bump-mapping the polaroid 'paper' ; 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. ; (define (script-fu-polaroid image drawable size colouring) (let* ( (imgWidth (car (gimp-image-width image))) (imgHeight (car (gimp-image-height image))) (sideoffset (abs (* 0.04 size))) (bottomoffset (* 4 sideoffset)) (pImgWidth size) (pImgHeight (+ pImgWidth bottomoffset)) (pImgSize (abs (- pImgWidth (* 2 sideoffset)))) (pTmp (car (gimp-image-new imgWidth imgHeight RGB))) (pTmpBackground (car (gimp-layer-new pTmp imgWidth imgHeight RGB "Background" 100 NORMAL ))) (pImg (car (gimp-image-new pImgWidth pImgHeight RGB))) (pImgBackground (car (gimp-layer-new pImg pImgWidth pImgHeight RGB "Background" 100 NORMAL ))) (pImgContent (car (gimp-layer-new pImg pImgSize pImgSize RGBA-IMAGE "Content" 100 NORMAL ))) ) ; disable undo on new image (gimp-image-undo-disable pImg) ; setup pTmp layer (gimp-image-add-layer pTmp pTmpBackground 0) ; setup pImg layers (gimp-image-add-layer pImg pImgBackground 0) (gimp-image-add-layer pImg pImgContent -1) (gimp-layer-set-offsets pImgContent sideoffset sideoffset) ; clear pImg background to white (gimp-palette-set-background '(255 255 255) ) (gimp-palette-set-foreground '(0 0 0) ) (gimp-selection-all pImg) (gimp-edit-clear pImgBackground) (gimp-selection-none pImg) ; copy content into pTmp, scale to pImgSize and then composite into pImg (gimp-edit-copy drawable) (gimp-floating-sel-anchor (car (gimp-edit-paste pTmpBackground TRUE))) (gimp-scale pTmpBackground TRUE 0 0 pImgSize pImgSize) (gimp-image-resize pTmp pImgSize pImgSize 0 0) (gimp-edit-copy pTmpBackground) (gimp-image-delete pTmp) (gimp-floating-sel-anchor (car (gimp-edit-paste pImgContent TRUE))) ; if requested colourify to traditional polaroid (if (= colouring TRUE) (begin (gimp-color-balance pImgContent SHADOWS TRUE 20 0 -20) (gimp-brightness-contrast pImgContent 0 20) ) ) ; enable undo on new image. (gimp-image-undo-enable pImg) ; dump new image to the user (gimp-display-new pImg) (gimp-displays-flush) ) ) (script-fu-register "script-fu-polaroid" _"/Script-Fu/Decor/Polaroid..." "Turn an image into a 'Polaroid' snap.\n\nImage widths larger than 170 pixels seem to yield the best results.\n\nEnjoy!" "Avi Bercovich " "Avi Bercovich" "April 2003" "RGB* GRAY* INDEXED*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-ADJUSTMENT "Image Width" '(256 32 16384 1 10 0 1) SF-TOGGLE "Polaroid Colouring?" TRUE )