PDA

Vollständige Version anzeigen : Proportionales Zuschneiden möglich?


cmathaes
23.03.2004, 15:32
Hallo!

Ich benutze Version 2.0 pre4 (=rc3?) unter Windows.

Ich muss oft Bilder zuschneiden, wobei das ursprüngliche Seitenverhältnis beibehalten werden soll (nicht die absolute Größe).

In anderen Programmen (von denen ich ja gern wegkommen möchte) geht das mit gedrückter Shift- oder Strg-Taste.
Man kann dann das ganze Bild auswählen und die Markierung proportional verkleinern, bis der gewünschte Ausschnitt erreicht ist.
Ich habe jedoch in GIMP keine solche Kombination herausgefunden.

Geht das überhaupt (ohne jetzt per Hand die Höhe und Breite auszurechnen :wink: )?

Vielen Dank für Eure Hilfe!

Carsten.

P. S.: Ich bin von dem Sprung in Sachen Bedienbarkeit zielmlich begeistert, den GIMP in letzter Zeit gemacht hat! Danke an alle Entwickler!

Wulf
23.03.2004, 18:18
strg+alt, beim klicken

cmathaes
25.03.2004, 13:08
Danke für die Hilfe!
Werde es gleich versuchen.

Mit freundlichen Grüßen

Carsten.

flashnfantasy
14.05.2004, 11:21
Versuche folgenden Script zu installieren.
'Ratio Max' in der Selection erzeugt automatisch aus einer beliebigen Auswahl eine Auswahl mit Seitenverhältniss. Das Ausschneiden und Scaling ist aber noch nicht dabei. Dafür gibt es aber ziemlich simple Werkzeuge.


(script-fu-register "selection"
_"<Image>/Script-Fu/Selection/Selection-Fit"
"Makes the selection fit to a ratio. Or make a 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"
_"Ratio Horizontal"
_"Ratio Vertical"
_"Horizontal"
_"Vertical")
SF-STRING _"X-Ratio" "1"
SF-STRING _"Y-Ratio" "1"
SF-OPTION _"Mask" '(_"None"
_"White 75%"
_"Black 75%"
_"Black 25%")
)

(define (selection inImage inLayer fit xrat yrat mask)
(set! select-bounds (gimp-selection-bounds inImage))
(set! has-selection (car select-bounds))
(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! dx (/ (- (/ (* (string->number xrat) (- y2 y1)) (string->number yrat)) (- x2 x1)) 2))
(set! dy (/ (- (/ (* (string->number yrat) (- x2 x1)) (string->number xrat)) (- y2 y1)) 2))
(set! dxh (/ (- (/ (* (string->number xrat) theHeight) (string->number yrat)) (- x2 x1)) 2))
(set! dyh (/ (- (/ (* (string->number yrat) theWidth) (string->number xrat)) (- y2 y1)) 2))
(set! dxha (/ (- (/ (* (string->number yrat) theHeight) (string->number xrat)) (- x2 x1)) 2))
(set! dyha (/ (- (/ (* (string->number xrat) theWidth) (string->number 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 5)
(begin
(set! nx1 0)
(set! nx2 theWidth)))

(if (= fit 6)
(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))))
))

; horizontal ratio fit
(if (= fit 3)
(begin
(set! nx1 0)
(set! nx2 theWidth)
(set! ny1 (- ny1 dyh))
(set! ny2 (+ ny2 dyh))
))


; vertical ratio fit
(if (= fit 4)
(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 (< 0 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 (= 2 mask)
(begin
(gimp-selection-invert inImage)
(gimp-levels layerMask 0 0 255 1 0 0)
(gimp-selection-invert inImage)
))
(if (= 3 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))

Wulf
14.05.2004, 11:31
Ist das von dir?

flashnfantasy
14.05.2004, 12:42
Ja, der Script ist von mir.

Wesentlich ist mir, daß der Script eine Vorauswahl berücksichtigt.

Was ich vielleicht noch erwähnen sollte:
'Auto' als Option sucht die größtmögliche Passform für das Bild und entscheidet dabei, ob das Bild gekippt wird.
Und wenn man die dann erzeugte Auswahl verschiebt über den Rand hinaus (was sich nicht immer vermeiden lässt), dann kann für alle Optionen dieser Script nochmals aufgerufen werden.