On Thu, 28 Mar 2013 19:09:11 +0000 Danny D. wrote:
> $ cp original.png foo.png
> $ gimp -i -b '(simple-seamless "foo.png")' -b '(gimp-quit 0)'
> $ cp foo.png foo_1.png; cp original.png foo.png
> $ gimp -i -b '(simple-illusion "foo.png" 8 1)' -b '(gimp-quit 0)'
> $ cp foo.png foo_2.png; cp original.png foo.png
> Now it's time to work on the next procedure.
The next operation is to replicate this command:
[GIMP]:Filters->Decor->Old Photo
[x]Defocus, Border size=20, [x]Sepia, [ ]Mottle, [ ]Work on copy
1. We find the desired procedure name to be "script-fu-old-photo"
[GIMP]:Help->Plug-In Browser->old photo
http://www2.picturepush.com/photo/a/12530755/img/12530755.png
2. That help tells us the 8 arguments to "script-fu-old-photo" are:
a. Interactive, non-interactive
b. The image
c. The layer
d. Defocus (toggle)
e. Border size (which we will set to 20.0)
f. Sepia (toggle)
g. Mottle (toggle)
h. Work on copy (toggle)
2. We create a script using the original tutorial template:
$ cd ~/.gimp-2.6/scripts
$ cp unsharp.scm simple-oldphoto.scm
$ vi !$
(define (simple-oldphoto filename defocus border sepia mottle workoncopy)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-old-photo RUN-NONINTERACTIVE
image drawable defocus border sepia mottle workoncopy)
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
3. We run GIMP, with values for defocus, border, sepia, mottle, & workoncopy:
Note: I'm assuming that the toggle takes true (t) or nil (n) arguments.
$ gimp -i -b '(simple-oldphoto "foo.png" t 20.0 t n n)' -b '(gimp-quit 0)'
REPORTED: batch command experienced an execution error
Note: I don't know HOW to get a better log file for the error (do you?).
4. Trying "0" for "nil" and "1" for "true":
$ gimp -i -b '(simple-oldphoto "foo.png" 1 20.0 1 0 0)' -b '(gimp-quit 0)'
REPORTS:
GIMP-Error: Calling error for procedure 'gimp-file-save':
Procedure 'gimp-file-save' has been called with an invalid ID for argument 'drawable'.
Most likely a plug-in is trying to work on a layer that doesn't exist any longer.
batch command experienced an execution error
5. NOTE: Hmmm... I remember something about that in the tutorial ...
http://www.gimp.org/tutorials/Basic_Batch/
Which warns:
[quote]
Some plugins or Script-Fu scripts create new layers and then flatten the image again.
This changes the drawable ID. If this is the case insert the following line to get
the current drawable ID just before saving the image
(set! drawable (car (gimp-image-get-active-layer image)))
[/quote]
6. So, let's see where we can add that line in the simple-oldphoto.scm script:
(define (simple-oldphoto filename defocus border sepia mottle workoncopy)
(let* ((image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image))))
(script-fu-old-photo RUN-NONINTERACTIVE
image drawable defocus border sepia mottle workoncopy)
(set! drawable (car (gimp-image-get-active-layer image)))
(gimp-file-save RUN-NONINTERACTIVE image drawable filename filename)
(gimp-image-delete image)))
7. Hmmm... there was no error - but we didn't get the old photo either:
$ gimp -i -b '(simple-oldphoto "foo.png" 1 20.0 1 0 0)' -b '(gimp-quit 0)'
REPORTS: batch command executed successfully
Comparing the original photo with the results, showed "something" happened,
but not what we had wanted to happen.
Need to debug ... WIP
NOTE: I wish there were better debugging procedures available or known!