Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Scripting-Help needed!

53 views
Skip to first unread message

Doreen Hausenblas

unread,
Sep 25, 2002, 8:16:09 PM9/25/02
to
Hi!

I am new to GIMP scripting. Using some scripting-tutorials found on the
web, I managed to create this "script":

-------------------script------------------

; pigeon_eye_edit_cc

(define (eye-edit-cc img
drawable)

(gimp-edit-copy drawable)
(set! img2 (car (gimp-image-new 600 530 RGB)))
(gimp-edit-paste img2 TRUE)

(gimp-display-new img2)
(gimp-displays-flush))

(script-fu-register "eye-edit-cc"
"<Image>/Script-Fu/eyes/eye_edit_cc"
"copy selection, paste as new image, resize to
425x*, apply color curve, save as jpg"
"do"
"do"
"2002-09-26"
"RGB*, GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0)

-------------------script------------------

But it does nothing except creating the new image. Maybe it copies the
selection out of the first image, but it doesn´t paste in into the new one.

What I want to do is:

- open an image manually
- make a selection in this image manually, size set to 600x530

And here the script should come in by pressing a single key.
The script shall:

- copy the 600x530 selection
- paste the 600x530 selection as a new image
- scale / resize the new image to a width of 425, heigth proportional
- apply a (saved-before) color-curve (named "xyz")
- save the image into a jpg-file called
"name_of_manually_opened_picture_and*user*entered*value*.jpg" with set
jpeg - parameters, such as quality = 100, progressive, floating-point,
1x1, 1x1, 1x1, optimize

Could anyone please help me writing this script? Or just tell me why my
tiny script doesn´t paste the copied selection into the new image?


Thank you :-)

regards,
Do

Branko Collin

unread,
Sep 25, 2002, 9:25:39 PM9/25/02
to
Doreen Hausenblas <doreenelch...@yahoo.de>, you wrote on Thu,
26 Sep 2002 02:16:09 +0200:

>I am new to GIMP scripting. Using some scripting-tutorials found on the
>web, I managed to create this "script":
>
>-------------------script------------------
>
>; pigeon_eye_edit_cc
>
>(define (eye-edit-cc img
> drawable)
>
> (gimp-edit-copy drawable)
> (set! img2 (car (gimp-image-new 600 530 RGB)))
> (gimp-edit-paste img2 TRUE)

I am not sure if this is the problem/solution, but for instance the
script select_to_image.scm uses some extra steps:

: (set! draw2 (car (gimp-layer-new img2 600 530 RGB "Selection" 100 NORMAL)))
: (gimp-image-add-layer img2 draw2 0)
: (gimp-drawable-fill draw2 BG-IMAGE-FILL)

Next, the selection gets pasted into the new drawable (the layer with
the name "Selection") instead of the new image. See also the PDB entry
for gimp-edit-paste.

Good luck,

--
branko collin
col...@xs4all.nl

Christian Muenscher

unread,
Sep 26, 2002, 5:26:39 PM9/26/02
to
Hi!

Branko Collin schrieb:


> I am not sure if this is the problem/solution, but for instance the
> script select_to_image.scm uses some extra steps:

> [..]

That was really great!

Now, after five hours of fiddling, googling and "coding", I惴 ready:
(see script below, works at least with win2k)
There are some things I still don愒 know about why they don愒 work,
but... I think the result is ok for never having created a GIMP-script
before...

Important sources:

http://people.delphiforums.com/gjc/siod.html
http://www.klaban.torun.pl/help/script-fu-tutorial/
http://pingus.seul.org/~grumbel/gimp/script-fu/script-fu-tut.html

and the scripts that are "hidden" in the gimp-dir :)

----------------------------- snip --------------------------

; pigeon_eye_edit_cc

(define (eye-edit-cc img
drawable
path
filename
width-selection
heigth-selection
width-scale
heigth-scale
gamma-toggle
gamma-value
)

(gimp-edit-copy drawable)
(set! img2 (car (gimp-image-new width-selection heigth-selection RGB)))
(set! draw2 (car (gimp-layer-new img2 width-selection
heigth-selection RGB "Selection" 100 NORMAL)))


(gimp-image-add-layer img2 draw2 0)
(gimp-drawable-fill draw2 BG-IMAGE-FILL)

; why doesn愒 that work? (gimp-edit-paste draw2 FALSE)

(let ((floating-sel (car (gimp-edit-paste draw2 FALSE))))
(gimp-floating-sel-anchor floating-sel)
)

(gimp-image-scale img2 width-scale heigth-scale)
(if (= gamma-toggle TRUE) (gimp-levels draw2 0 0 255 gamma-value 0 255))
; alternative to the above? (gimp-brightness-contrast draw2 50 0)

(gimp-selection-none img)
(gimp-display-new img2)
(gimp-displays-flush)
(define filename (string-append path filename))
(file-jpeg-save 1 img2 draw2 filename filename 0.95 0 1 1 "Created
with The GIMP by Crion" 2 1 0 2)
(gimp-image-clean-all img2))

(script-fu-register "eye-edit-cc"
"<Image>/Script-Fu/eyes/eye_edit_cc"
"copy selection (600x530 max), paste as new image
(600x530), resize to 425x375, set gamma to 2, save as jpg with really
good quality"


"do"
"do"
"2002-09-26"
"RGB*, GRAY*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0

SF-STRING "path:" "e:/hofmann_cd/temp/"
SF-STRING "filename:" "seite__.jpg"
SF-VALUE "width of selection:" "600"
SF-VALUE "heigth of selection:" "530"
SF-VALUE "width of new image:" "425"
SF-VALUE "width of selection:" "375"
SF-TOGGLE "gamma correction:" TRUE
SF-VALUE "gamma value:" "2"
)

----------------------------- snip --------------------------

thanks again!

regards,
Chriss

P.S: Yes, my name changed - this time its mine :)

Christian Muenscher

unread,
Sep 26, 2002, 7:33:23 PM9/26/02
to
Hi!

Now I wanted to get a part of the filename of the original image:

(define filename_original car((gimp-image-get-filename img)))
(set! page_count (cons (strbreakup filename_original "_")))

the filename contains an "_"...
then I tried to save the file..

(define filename (string-append path fn_piece_1 page_count fn_piece_2))
(file-jpeg-save 1 img2 draw2 filename filename 0.95 0 1 1 "G" 2 1 0 2)

but here it reports an error - looks like string-append doesn´t create a
real string or something like that.

Can you help me how to create my own filenames? Then I´m done :)

Thanks,
Chriss

0 new messages