Am Donnerstag, 15. August 2002 13:59 schrieb Joel: > To copy the visible parts of the image, use these pdb functions: > > gimp_image_merge_visible_layers # combine layers in original file > gimp_rect_select # create a selection (in >original) > gimp_edit_copy # copy original to clipboard > gimp_edit_paste # paste it as a new floating >layer > > Exact parameters, and a bit of documentation, are in the PDB. (/Xtns/DB > Browser ...)
That's exactly what I thought. But it doesn't seem to work. If you don't mind, I'll give you my code so far (no loop for the next three pics yet): (define (mm-to-pixel mm xy) (if (= xy 0) (+ (* (/ mm 25.4) (car (gimp-get-monitor-resolution))) 0.5) (+ (* (/ mm 25.4) (cadr (gimp-get-monitor-resolution))) 0.5) ) ) (define (script-fu-dina4-4 sheet-border-mm path-1) (let*( (din-a4-x (mm-to-pixel 297 0)) (din-a4-y (mm-to-pixel 210 1)) (sheet-width (- din-a4-x (* (mm-to-pixel sheet-border-mm 0) 2))) (sheet-height (- din-a4-y (* (mm-to-pixel sheet-border-mm 1) 2))) (sheet-ratio (/ sheet-width sheet-height)) (sheet (car (gimp-image-new sheet-width sheet-height RGB))) (pic-1 (car (gimp-file-load 1 path-1 path-1))) (pic-width (car (gimp-image-width pic-1))) (pic-height (car (gimp-image-height pic-1))) (pic-ratio (/ pic-width pic-height)) ;next 2 lines: minus 2 pixel for a small white line between the four pictures (new-pic-width (- (/ sheet-width 2) 2)) (new-pic-height (- (/ sheet-height 2) 2)) (layer-1 (car (gimp-layer-new sheet new-pic-width new-pic-height 0 "Up-left" 100 0))) ) ; if the picture is portrait, it must be made landscape: (if (< pic-ratio 1.0) (begin (plug-in-rotate 0 pic-1 pic-1 3 TRUE) (set! pic-width (car (gimp-image-width pic-1))) (set! pic-height (car (gimp-image-height pic-1))) (set! pic-ratio (/ pic-width pic-height)) ) ) ; the picture must fit either high or wide, depending on its ratio: (if (< pic-ratio sheet-ratio) (set! new-pic-width (* new-pic-height pic-ratio)) (set! new-pic-height (/ new-pic-width pic-ratio)) ) (gimp-image-scale pic-1 new-pic-width new-pic-height) (if (> (car (gimp-image-get-layers pic-1)) 1) (gimp-image-merge-visible-layers pic-1 1) ) (gimp-image-add-layer sheet layer-1 0) (gimp-rect-select pic-1 0 0 new-pic-width new-pic-height 0 FALSE 0) (gimp-edit-copy (car (gimp-image-get-selection pic-1))) (gimp-edit-paste layer-1 0) (gimp-display-new sheet) ; testing just to see the scaling: (gimp-display-new pic-1) (gimp-image-clean-all sheet) (gimp-image-clean-all pic-1) ) ) (script-fu-register "script-fu-dina4-4" "<Toolbox>/Xtns/Script-Fu/VierLaden" "Erzeugt eine DINA4-Seite mit 4 Bildern zur Druckausgabe" "Volker Lenhardt" "GNU, Volker Lenhardt" "12. August 2002" "" SF-VALUE "Seitenrand (mm)" "10" SF-FILENAME "Datei" "/bilder/" ) If you try it out you'll find that the selection in pic-1 isn't in the edit-buffer, there's a white area instead. What is wrong with my script? > > Note that if you just select, then copy, and then paste, Gimp will put the > floating layer in the center of the new document. Use the > gimp_layer_translate function to move it to where you want it to go. In > Python (not sure what the equivalent is in Scheme), I use this code to find > the physical dimensions of the stuff I want to copy, taking transparency > into consideration: As I define a layer in "sheet" with exactly the wanted dimensions there's no need for me to change the default middle position. Sure I have to position the next three layers to their quarters. > > pdb.gimp_selection_layer_alpha(originalFile.layers[0]) > empty, x1, y1, x2, y2 = pdb.gimp_selection_bounds(originalFile) > > Then, using that, I'll calculate the top/right position : > > x = (x1 + x2 - originalFile.width) / 2 > y = (y1 + y2 - originalFile.width) / 2 > > # Now, adjust for the position where the old image should be put into > the # new image > x = x + top # top and left are values that I pass in > y = y + left > > pdb.gimp_layer_translate(floatLayer, x, y) I'm very curious. Greetings from Volker -- Volker Lenhardt Am Spinnweg 19, 45894 Gelsenkirchen, Germany Tel.: 0209-30213 - Fax: 0209-390437 Email: [EMAIL PROTECTED] _______________________________________________ Gimp-user mailing list [EMAIL PROTECTED] http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user