; split-image.scm ; ; Original version : 21/04/03 ; Version 0.1a Raymond Ostertag 2004/09 ; - Changed menu entry (define (script-fu-selection-split-image image drawable nbcol nbrow savepath) ( let* ( (iwidth (car (gimp-image-width image))) (iheight (car (gimp-image-height image))) (incX ( / iwidth nbcol)) (incY ( / iheight nbrow)) (ystart 0) (xstart 0) (draw-type (car (gimp-drawable-type-with-alpha drawable))) (image-type (car (gimp-image-base-type image))) (old-bg (car (gimp-palette-get-background))) (savename "") (postfix 0) (ypiecescount 0) (xcount 0) (ycount 0) (ypieces (* nbcol nbrow)) ) (gimp-image-undo-disable image) (while (< ypiecescount ypieces) (set! xcount 0) (set! xstart 0) (while (< xcount nbcol) (gimp-rect-select image xstart ystart incX incY REPLACE FALSE 0) (gimp-edit-copy drawable) (set! new-image (car (gimp-image-new incX incY image-type))) (set! new-draw (car (gimp-layer-new new-image incX incY draw-type "Selection" 100 NORMAL))) (gimp-image-add-layer new-image new-draw 0) (gimp-drawable-fill new-draw BG-IMAGE-FILL) (let ( (floating-sel (car (gimp-edit-paste new-draw FALSE))) ) (gimp-floating-sel-anchor floating-sel) ) (set! savename (string-append savepath (number->string postfix))) (set! savename (string-append savename ".gif")) (set! postfix (+ postfix 1)) ; (gimp-message savename) (gimp-convert-indexed new-image 3 0 256 FALSE FALSE "") (gimp-file-save 1 new-image new-draw savename savename) (gimp-image-set-active-layer image drawable) (set! xstart (+ xstart incX)) (set! ypiecescount (+ ypiecescount 1)) (set! xcount (+ xcount 1)) ) (set! ystart (+ ystart incY)) ) (gimp-image-undo-enable image) (gimp-palette-set-background old-bg) (gimp-displays-flush) ) ) (script-fu-register "script-fu-selection-split-image" "/Script-Fu/Utils/Split an Image from Selection..." "Split an image to rows and col and save the images as indexed gif's works on flattened RGB Images-Only (Based on split by Christian Schlange" "Philippe Rochat " "Philippe Rochat" "21/04/2003" "RGB* GRAY*" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 SF-VALUE "nbcol:" "2" SF-VALUE "nbrow:" "3" SF-FILENAME "filename (w/o ext): " "" )