Urban Acid script (buggy)
This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
Urban Acid script (buggy) | Dave 77459 | 07 Nov 21:43 |
Urban Acid script (buggy) | rcook@pcug.org.au | 07 Nov 22:09 |
Urban Acid script (buggy) | rcook@pcug.org.au | 07 Nov 22:14 |
Urban Acid script (buggy) | Dave 77459 | 08 Nov 01:06 |
Urban Acid script (buggy) | Kevin Cozens | 08 Nov 02:29 |
Urban Acid script (buggy) | Dave 77459 | 08 Nov 15:11 |
Urban Acid script (buggy)
Following is my "Urban Acid" Script-Fu program. It attempts to simulate the famous Photoshop Urban Acid action, which dramatically alters the color curves.
The program worked well in GIMP 2.2, but is buggy in v2.4. I am having the following problems:
* The first time, it runs but the working layer shows no difference. Indeed, even the mode is not set to overlay.
* The second time executed, not seems to happen. Not even a copy layer is created.
* GIMP seems to increasingly act weird after that. Scripts may or may not run. The entire experience looks like a memory over run.
I am now running GIMP 2.4.1 under Windows, but I saw the same thing in 2.4under Windows and also Ubuntu (Gutsy Gibbon).
Thanks for any help. Source follows.
Dave
--------------------------
; Urban Acid
; David Hathaway
;
; A script to fake the "Urban Acid" look within The Gimp version 2.
;
; This script is based on:
;
http://www.scrapjazz.com/community/jazzclub/showthread.php?t=89073&page=3&pp=15
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
; Version 0.5 - first working version
; Version 0.6 - modified to work on GIMP 2.4
(define (urban-acid img drawable)
; set some system variables
(let*
(
(copy-layer)
(splineValue)
(splineRed)
(splineGreen)
(splineBlue)
(a)
)
;7) create a duplicate layer of the base layer. (set! copy-layer (car (gimp-layer-copy drawable 0))) (gimp-layer-set-name copy-layer "Copy") (gimp-image-add-layer img copy-layer 0)
(define (splineValue)
(let* ((a (cons-array 10 'byte)))
(set-pt a 0 0 0)
(set-pt a 1 44 27)
(set-pt a 2 99 117)
(set-pt a 3 195 229)
(set-pt a 4 255 255)
a
)
)
(gimp-curves-spline copy-layer VALUE-LUT 10 (splineValue))
(define (splineRed)
(let* ((a (cons-array 10 'byte)))
(set-pt a 0 0 0)
(set-pt a 1 51 6)
(set-pt a 2 151 137)
(set-pt a 3 204 228)
(set-pt a 4 255 255)
a
)
)
(gimp-curves-spline copy-layer RED-LUT 10 (splineRed))
(define (splineGreen)
(let* ((a (cons-array 10 'byte)))
(set-pt a 0 0 0)
(set-pt a 1 38 31)
(set-pt a 2 125 129)
(set-pt a 3 197 223)
(set-pt a 4 255 255)
a
)
)
(gimp-curves-spline copy-layer GREEN-LUT 10 (splineGreen))
(define (splineBLue)
(let* ((a (cons-array 8 'byte)))
(set-pt a 0 0 0)
(set-pt a 1 22 33)
(set-pt a 2 149 126)
(set-pt a 4 255 255)
a
)
)
(gimp-curves-spline copy-layer BLUE-LUT 8 (splineRed))
(gimp-layer-set-mode copy-layer HARDLIGHT-MODE) (gimp-layer-set-opacity copy-layer 80)
) ; let*
; Flush the display
(gimp-displays-flush)
)
(script-fu-register "urban-acid"
"U_rban Acid"
"This script sets the curves based on the Urban Acid
formula"
"David Hathaway "
"(c) David Hathaway"
"2007 11 01"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer to start on (unused)" 0
)
(script-fu-menu-register "urban-acid"
"/Filters/Dave77459")
; "/Script-Fu")
Urban Acid script (buggy)
Following is my "Urban Acid" Script-Fu program. It attempts to simulate
the
famous Photoshop Urban Acid action, which dramatically alters the color
curves.
The program worked well in GIMP 2.2, but is buggy in v2.4. I am having the following problems:
* The first time, it runs but the working layer shows no difference.
Indeed, even the mode is not set to overlay.
* The second time executed, not seems to happen. Not even a copy layer
is
created.
* GIMP seems to increasingly act weird after that. Scripts may or may
not
run. The entire experience looks like a memory over run.
I am now running GIMP 2.4.1 under Windows, but I saw the same thing in
2.4under Windows and also Ubuntu (Gutsy Gibbon).
Using Ubuntu-7.4
Gimp-2.2 the script works fine
Running on Gimp-2.4 throws the following error
Error while executing
(urban-acid 1 2)
Error: eval: unbound variable: set-pt
But I am not up with Script-fu so will leave debugging to others
Owen
Urban Acid script (buggy)
Following is my "Urban Acid" Script-Fu program. It attempts to
simulate
the
famous Photoshop Urban Acid action, which dramatically alters the color
curves.
The program worked well in GIMP 2.2, but is buggy in v2.4. I am having
the
following problems:
* The first time, it runs but the working layer shows no difference.Indeed, even the mode is not set to overlay.
* The second time executed, not seems to happen. Not even a copy layer
is
created.
* GIMP seems to increasingly act weird after that. Scripts may or maynot
run. The entire experience looks like a memory over run. I am now running GIMP 2.4.1 under Windows, but I saw the same thing in
2.4under Windows and also Ubuntu (Gutsy Gibbon).
Using Ubuntu-7.4
Gimp-2.2 the script works fine
Running on Gimp-2.4 throws the following error
Error while executing (urban-acid 1 2)
Error: eval: unbound variable: set-ptBut I am not up with Script-fu so will leave debugging to others
Ah ha, read some more mail, and this one from Tobias Jakobs points to the Script-fu changes which include;
By far, the most common problem that can be expected if using an older script is that it might assign a value to a variable without first declaring the variable. SIOD-based Script-fu would permit a statement such as (set! x 4) even if 'x' had not been declared -- 'x' would be defined automatically to be a global variable. The new Script-fu protects against this situation and the programmer must declare the variable first. The offending script would result in an error message stating, "Error: set!: unbound variable: x".
Owen
Urban Acid script (buggy)
Owen,
Thanks for confirming that it works in 2.2 under Ubuntu and crashes on 2.4.
I too got that unbound error on 2.4 . I declared all the variables, which cleared that up under Windows. I still got the unbound error in Ubuntu, which is odd since set-pt is a function, not a variable??
So I added this in the hopes it would clear up:
; define the set-pt procedure (used to be embedded??)
; from http://adrian.gimp.org/scripts/shagadelic.scm
(define (set-pt a index x y)
(prog1
(aset a (* index 2) x)
(aset a (+ (* index 2) 1) y)
)
)
This is added before the "(define (splineValue)"
It appears that set-pt is defined ("built-in?") in the Windows 2.4.1 build but not Ubuntu 2.4?
However, with that function thus defined, the Ubuntu version behaves as quirkily as the Windows version. Doesn't appear to do anything, but proceeds to make GIMP act weirdly.
This odd behavior is why I am appealing for help. I appreciate your sleuthing.
Dave
On Nov 7, 2007 3:14 PM, wrote:
Following is my "Urban Acid" Script-Fu program. It attempts to
simulate
the
famous Photoshop Urban Acid action, which dramatically alters the color
curves.
The program worked well in GIMP 2.2, but is buggy in v2.4. I am having
the
following problems:
* The first time, it runs but the working layer shows no difference.Indeed, even the mode is not set to overlay.
* The second time executed, not seems to happen. Not even a copy layer
is
created.
* GIMP seems to increasingly act weird after that. Scripts may or maynot
run. The entire experience looks like a memory over run. I am now running GIMP 2.4.1 under Windows, but I saw the same thing in
2.4under Windows and also Ubuntu (Gutsy Gibbon).
Using Ubuntu-7.4
Gimp-2.2 the script works fine
Running on Gimp-2.4 throws the following error
Error while executing (urban-acid 1 2)
Error: eval: unbound variable: set-ptBut I am not up with Script-fu so will leave debugging to others
Ah ha, read some more mail, and this one from Tobias Jakobs points to the Script-fu changes which include;
By far, the most common problem that can be expected if using an older script is that it might assign a value to a variable without first declaring the variable. SIOD-based Script-fu would permit a statement such as (set! x 4) even if 'x' had not been declared -- 'x' would be defined automatically to be a global variable. The new Script-fu protects against this situation and the programmer must declare the variable first. The offending script would result in an error message stating, "Error: set!: unbound variable: x".
Owen
Urban Acid script (buggy)
Dave 77459 wrote:
Owen,
Thanks for confirming that it works in 2.2 under Ubuntu and crashes on 2.4.
I too got that unbound error on 2.4 . I declared all the variables, which cleared that up under Windows. I still got the unbound error in Ubuntu, which is odd since set-pt is a function, not a variable??
So I added this in the hopes it would clear up:
; define the set-pt procedure (used to be embedded??) ; from http://adrian.gimp.org/scripts/shagadelic.scm (define (set-pt a index x y)
[snip]
The script calls set-pt but did not define the function. In GIMP 2.2 functions in one file were defined in a way that made them available to be called by scripts in other files. While this can be a useful feature at times it can also cause problems.
There were two scripts that defined point-list->double-array which took one argument. The routines were different and as a result, one of the two scripts appeared to be broken as it wound up calling the wrong version of the function.
As of GIMP 2.4, the scripts which ship as part of the Script-Fu plug-in define the functions they need locally (ie. other scripts can't access them). This avoids the problems of adding a new script and finding out that some other previously working script no longer works.
Urban Acid script (buggy)
Kevin,
Thank you giving me this information. It is really useful to know. I think it ought to be part of the Migration guide, because naive script writers like me don't know that functions like set-pt are locally defined. I thought I was using a built-in function.
It is further confused by the fact that the Windows version *does not* complain that set-pt is not defined. It is apparently defined elsewhere and is being found.
To my mind, set-pt is either a global function or must declared locally and if GIMP is finding a local function, then this is a bug. It is being handled two different ways; perhaps it is a 2.4.0 versus 2.4.1 difference?
Thanks for your help. I think I'll try a different way of setting the splines since this is static.
Dave
On Nov 7, 2007 7:29 PM, Kevin Cozens wrote:
Dave 77459 wrote:
Owen,
Thanks for confirming that it works in 2.2 under Ubuntu and crashes on
2.4.
I too got that unbound error on 2.4 . I declared all the variables, which cleared that up under Windows. I still got the unbound error in Ubuntu, which is odd since set-pt is a function, not a variable??
So I added this in the hopes it would clear up:
; define the set-pt procedure (used to be embedded??) ; from http://adrian.gimp.org/scripts/shagadelic.scm (define (set-pt a index x y)
[snip]
The script calls set-pt but did not define the function. In GIMP 2.2functions in one file were defined in a way that made them available to be called by scripts in other files. While this can be a useful feature at times it can also cause problems.
There were two scripts that defined point-list->double-array which took one
argument. The routines were different and as a result, one of the two scripts
appeared to be broken as it wound up calling the wrong version of the function.As of GIMP 2.4, the scripts which ship as part of the Script-Fu plug-in define
the functions they need locally (ie. other scripts can't access them). This
avoids the problems of adding a new script and finding out that some other previously working script no longer works.-- Cheers!
Kevin.
http://www.ve3syb.ca/ |"What are we going to do today, Borg?" Owner of Elecraft K2 #2172 |"Same thing we always do, Pinkutus: | Try to assimilate the world!" #include | -Pinkutus & the Borg