Hallo allerseits,
ich bearbeite meine Digitalbilder vorm Ausbelichten lassen gern passend für den jeweiligen Ausbelichter, schneide sie also auch auf die richtigen Pixelmaße zu. Nun kann man sich ja auch schnell mal vertippen bei den Pixelzahlen...
Frage 1: Kann man den Zuschneiden-Dialog irgendwie per Script-Fu mit Vorgabewerten aufrufen?
Frage 2: Ich habe selber schon mal ein wenig mit Script-Fu rumgebastelt:
(define (script-fu-create-selection-rossmann-10x15 Image Drawable X Y Width Height)
; Start Undo-Gruppe
(gimp-undo-push-group-start Image)
; Selektion markieren
(gimp-rect-select Image X Y Width Height 2 0 0)
; Ende Undo-Gruppe
(gimp-undo-push-group-end Image)
)
(script-fu-register "script-fu-create-selection-rossmann-10x15"
_"<Image>/Script-Fu/Selection/Rossmann 10x15"
"Zuschnitt für Rossmann 10x15"
"Uwe Naumann <uwe@vieledinge.de>"
"Uwe Naumann"
"09/03/04"
"RGB* GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT "X" '(0 1 20000 1 1 0 1)
SF-ADJUSTMENT "Y" '(0 1 20000 1 1 0 1)
SF-ADJUSTMENT "Breite" '(1820 1 20000 1 1 0 1)
SF-ADJUSTMENT "Höhe" '(1230 1 20000 1 1 0 1)
)
Das zeichnet schon mal den passenden Auswahl-Rahmen. Leider macht es das erst nach dem Schließen des Dialoges mit OK. Kann man das auch während der Einstellung schon zeichnen lassen analog dem Zuschneiden-Dialog? Hat da jemand mal einen passenden Hinweis für mich?
Danke schon mal im Voruas.
flashnfantasy
04.09.2004, 07:54
Da Problem hatte ich auch, die Digicam macht ein Bild im Verhältniss 4:3, aber für mein Album wollte ich das Verhältniss 3:2, für den Posterdrucker brauchte ich das Verhälniss 38:28, Panoramas ganz klar 3:1 usw...
Der folgende Scripte arbeitet auf der Basis des Verhältnisses, d.h. man gib als Parameter die Seitenverhältnisse ein.
Der Script wandelt einen ausgewählten Bereich in eine Auswahl mit dem vorgesehenen Seitenverhältniss um,
und, ganz wichtig, verschiebt die Auswahl nach Möglichkeit, so daß sie aufs Bild passt.
Vorgeben muß man also eine Auswahl, wo ich das Lasso bevorzuge
Zu zwei Menüpunkten
Auto - schneidet ein Rechteck so aus dem Bild, daß möglichst viel von dem Bild in das Rechteck passt, eigentlich immer die beste Wahl, wenn man das Bild ohne viel Verlust zuschneiden will
Ratio Max - Mein Favorit für Ausschnittvergrößerungen, er wandelt die Auswahl in ein Rechteck mit den vorgegebenen Seitenverhältnissen um, verschiebt das Rechteck gegebenenfalls, so daß alles auf dem Bild ist...
(script-fu-register "selection"
_"<Image>/Script-Fu/Selection/Selection-Fit"
"Makes the selection fit to a ratio. Or Make an horizontal/vertical stripe."
"Mathias Weitz"
"Mathias Weitz"
"18/07/03"
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-OPTION _"Fit" '(_"Auto"
_"Ratio Max"
_"Ratio Min"
_"Exact"
_"Ratio Horizontal"
_"Ratio Vertical"
_"Horizontal"
_"Vertical")
SF-ADJUSTMENT _"X-Ratio" '(1 1 100 1 1 0 0)
SF-ADJUSTMENT _"Y-Ratio" '(1 1 100 1 1 0 0)
SF-OPTION _"Mask" '(_"None"
_"New Image"
_"White 75%"
_"Black 75%"
_"Black 25%")
SF-ADJUSTMENT _"New-Image Width\n0 = no Scaling" '(0 0 3000 100 100 0 0)
)
(define (selection inImage inLayer fit xrat yrat mask finalWidth)
(set! select-bounds (gimp-selection-bounds inImage))
(set! has-selection (car select-bounds))
; x1 und y1 sind die Startkoordinaten
; x2 und y1 sind die Endkoordinaten
(set! x1 (cadr select-bounds))
(set! y1 (caddr select-bounds))
(set! x2 (cadr (cddr select-bounds)))
(set! y2 (caddr (cddr select-bounds)))
(set! theWidth (car (gimp-image-width inImage)))
(set! theHeight (car (gimp-image-height inImage)))
(set! ergImg inImage)
; Sprachgebrauch:
; OS ist die Originalselektion
; ZS ist die Zielselektion, also die Selektion, die man erzeugen will.
; B ist das Bild insgesamt
; x ist die HALBE!!! Breite der Selektion in Pixel
; y ist die HALBE!!! Höhe der Selektion in Pixel
;
; Es wird immer die andere Größe des kartesischen Koordinatensystems bestimmt,
; wenn man das korrekte Verhältniss haben will.
;
; dx = die Differenz zu x der ZS vom x der OS wenn man man y der OS als Grundlage nimmt.
; dy ebenso
; dxh = die Differenz zu x der ZS vom x des B wenn man man y des B als Grundlage nimmt.
; dyh ebenso
;
; die beiden folgenden Werte sind nur interessant für die automatische
; Auswahl, bei der das Verhältniss auch gekippt wird, wenn dadurch
; mehr Bild in die Auswahl kommt !!!
; dxha = die Differenz zu x der ZS vom x des B wenn man man x! des B als Grundlage nimmt.
; dyha ebenso
(set! dx (/ (- (/ (* xrat (- y2 y1)) yrat) (- x2 x1)) 2))
(set! dy (/ (- (/ (* yrat (- x2 x1)) xrat) (- y2 y1)) 2))
(set! dxh (/ (- (/ (* xrat theHeight) yrat) (- x2 x1)) 2))
(set! dyh (/ (- (/ (* yrat theWidth) xrat) (- y2 y1)) 2))
(set! dxha (/ (- (/ (* yrat theHeight) xrat) (- x2 x1)) 2))
(set! dyha (/ (- (/ (* xrat theWidth) yrat) (- y2 y1)) 2))
(set! nx1 x1)
(set! nx2 x2)
(set! ny1 y1)
(set! ny2 y2)
(if (= fit 0)
(begin
(set! s 1)
(if (and (and (<= (+ (- y2 y1) (* 2 dyh)) theHeight) (<= 0 dyh)) (= s 1))
(begin
(set! nx1 0)
(set! nx2 theWidth)
(set! ny1 (- ny1 dyh))
(set! ny2 (+ ny2 dyh))
(set! s 0)
))
(if (and (and (<= (+ (- x2 x1) (* 2 dxh)) theWidth) (<= 0 dxh)) (= s 1))
(begin
(set! ny1 0)
(set! ny2 theHeight)
(set! nx1 (- nx1 dxh))
(set! nx2 (+ nx2 dxh))
(set! s 0)
))
(if (and (and (<= (+ (- y2 y1) (* 2 dyha)) theHeight) (<= 0 dyha)) (= s 1))
(begin
(set! nx1 0)
(set! nx2 theWidth)
(set! ny1 (- ny1 dyha))
(set! ny2 (+ ny2 dyha))
(set! s 0)
))
(if (and (and (<= (+ (- x2 x1) (* 2 dxha)) theWidth) (<= 0 dxha)) (= s 1))
(begin
(set! ny1 0)
(set! ny2 theHeight)
(set! nx1 (- nx1 dxha))
(set! nx2 (+ nx2 dxha))
(set! s 0)
))
))
(if (= fit 6)
(begin
(set! nx1 0)
(set! nx2 theWidth)))
(if (= fit 7)
(begin
(set! ny1 0)
(set! ny2 theHeight)))
(if (= fit 1)
(begin
(if (< 0 dx)
(begin
(set! nx1 (- nx1 dx))
(set! nx2 (+ nx2 dx))))
(if (< 0 dy)
(begin
(set! ny1 (- ny1 dy))
(set! ny2 (+ ny2 dy))))
))
(if (= fit 2)
(begin
(if (< 0 dy)
(begin
(set! nx1 (- nx1 dx))
(set! nx2 (+ nx2 dx))))
(if (< 0 dx)
(begin
(set! ny1 (- ny1 dy))
(set! ny2 (+ ny2 dy))))
))
; exact fit
(if (= fit 3)
(begin
(set! nx1 (- (/ (+ nx1 nx2) 2) (/ xrat 2)))
(set! nx2 (+ nx1 xrat))
(set! ny1 (- (/ (+ ny1 ny2) 2) (/ yrat 2)))
(set! ny2 (+ ny1 yrat))
))
; horizontal ratio fit
(if (= fit 4)
(begin
(set! nx1 0)
(set! nx2 theWidth)
(set! ny1 (- ny1 dyh))
(set! ny2 (+ ny2 dyh))
))
; vertical ratio fit
(if (= fit 5)
(begin
(set! ny1 0)
(set! ny2 theHeight)
(set! nx1 (- nx1 dxh))
(set! nx2 (+ nx2 dxh))
))
(if (< theWidth nx2)
(begin
(set! nx1 (- nx1 (- nx2 theWidth)))
(set! nx2 theWidth)))
(if (< nx1 0)
(begin
(set! nx2 (- nx2 nx1))
(set! nx1 0)))
(if (< theHeight ny2)
(begin
(set! ny1 (- ny1 (- ny2 theHeight)))
(set! ny2 theHeight)))
(if (< ny1 0)
(begin
(set! ny2 (- ny2 ny1))
(set! ny1 0)))
(gimp-rect-select inImage
nx1
ny1
(- nx2 nx1)
(- ny2 ny1)
REPLACE
FALSE 0)
(if (= 1 mask)
(begin
; Neues Fenster
(set! image-work (car (gimp-image-new (- nx2 nx1) (- ny2 ny1) RGB)))
;(gimp-image-undo-disable image-work)
(set! image-new-layer (car (gimp-layer-new image-work (- nx2 nx1) (- ny2 ny1) RGB "Hintergrund" 100 NORMAL)))
(gimp-image-add-layer image-work image-new-layer 0)
(set! display-work (car (gimp-display-new image-work)))
(gimp-edit-copy inLayer)
(gimp-selection-all image-work)
(gimp-layer-add-alpha image-new-layer)
(gimp-drawable-fill image-new-layer 3)
(gimp-edit-clear image-new-layer)
(gimp-selection-clear image-work)
(set! floating_sel (car (gimp-edit-paste image-new-layer 0)))
(gimp-floating-sel-anchor floating_sel)
(if (< 0 finalWidth)
(gimp-image-scale image-work finalWidth (* (/ (- ny2 ny1) (- nx2 nx1)) finalWidth)))
(set! ergImg image-work)
))
(if (< 1 mask)
(begin
(set! layerMask (car (gimp-layer-new inImage (car (gimp-image-width inImage)) (car (gimp-image-height inImage)) 1 "Maske" 90 0)))
(gimp-image-add-layer inImage layerMask 0)
(gimp-drawable-fill layerMask 2)
(gimp-edit-clear layerMask)
(if (= 3 mask)
(begin
(gimp-selection-invert inImage)
(gimp-levels layerMask 0 0 255 1 0 0)
(gimp-selection-invert inImage)
))
(if (= 4 mask)
(begin
(gimp-selection-invert inImage)
(gimp-levels layerMask 0 0 255 1 0 0)
(gimp-selection-invert inImage)
(gimp-layer-set-opacity layerMask 25)
))
))
(gimp-image-clean-all inImage)
(gimp-displays-flush)
(cons ergImg)
)
vBulletin® v3.8.2, Copyright ©2000-2013, Jelsoft Enterprises Ltd.