1998-04-09 05:32:04 -07:00
|
|
|
;;; unsharp-mask.scm
|
1998-11-25 13:18:26 -08:00
|
|
|
;;; Time-stamp: <1998/11/17 13:18:39 narazaki@gimp.org>
|
|
|
|
|
;;; Author: Narazaki Shuji <narazaki@gimp.org>
|
|
|
|
|
;;; Version 0.8
|
1998-04-09 05:32:04 -07:00
|
|
|
|
1998-11-25 13:18:26 -08:00
|
|
|
(define (script-fu-unsharp-mask img drw mask-size mask-opacity)
|
2006-10-15 18:08:54 -07:00
|
|
|
(let* (
|
2021-04-20 08:47:11 -07:00
|
|
|
(drawable-width (car (gimp-drawable-get-width drw)))
|
|
|
|
|
(drawable-height (car (gimp-drawable-get-height drw)))
|
2006-10-15 18:08:54 -07:00
|
|
|
(new-image (car (gimp-image-new drawable-width drawable-height RGB)))
|
|
|
|
|
(original-layer (car (gimp-layer-new new-image
|
|
|
|
|
drawable-width drawable-height
|
|
|
|
|
RGB-IMAGE "Original"
|
2017-01-09 11:37:30 -08:00
|
|
|
100 LAYER-MODE-NORMAL)))
|
2008-01-14 21:15:08 -08:00
|
|
|
(original-layer-for-darker 0)
|
|
|
|
|
(original-layer-for-lighter 0)
|
2018-05-12 09:13:12 -07:00
|
|
|
(blurred-layer-for-darker 0)
|
|
|
|
|
(blurred-layer-for-lighter 0)
|
2008-01-14 21:15:08 -08:00
|
|
|
(darker-layer 0)
|
|
|
|
|
(lighter-layer 0)
|
2006-10-15 18:08:54 -07:00
|
|
|
)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
1998-04-09 05:32:04 -07:00
|
|
|
(gimp-selection-all img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 13:40:19 -07:00
|
|
|
(gimp-edit-copy 1 (vector drw))
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
1999-10-16 17:07:55 -07:00
|
|
|
(gimp-image-undo-disable new-image)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
2011-03-01 23:55:43 -08:00
|
|
|
(gimp-image-insert-layer new-image original-layer 0 0)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 13:40:19 -07:00
|
|
|
|
|
|
|
|
(let* (
|
|
|
|
|
(pasted (gimp-edit-paste original-layer FALSE))
|
|
|
|
|
(num-pasted (car pasted))
|
|
|
|
|
(floating-sel (aref (cadr pasted) (- num-pasted 1)))
|
|
|
|
|
)
|
|
|
|
|
(gimp-floating-sel-anchor floating-sel)
|
|
|
|
|
)
|
2004-01-26 07:34:47 -08:00
|
|
|
|
1998-04-09 05:32:04 -07:00
|
|
|
(set! original-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
|
|
|
|
|
(set! original-layer-for-lighter (car (gimp-layer-copy original-layer TRUE)))
|
2018-05-12 09:13:12 -07:00
|
|
|
(set! blurred-layer-for-darker (car (gimp-layer-copy original-layer TRUE)))
|
2010-08-02 14:13:51 -07:00
|
|
|
(gimp-item-set-visible original-layer FALSE)
|
1998-04-09 05:32:04 -07:00
|
|
|
(gimp-display-new new-image)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
1998-04-09 05:32:04 -07:00
|
|
|
;; make darker mask
|
2018-05-12 09:13:12 -07:00
|
|
|
(gimp-image-insert-layer new-image blurred-layer-for-darker 0 -1)
|
2007-10-01 01:42:48 -07:00
|
|
|
(plug-in-gauss-iir RUN-NONINTERACTIVE
|
2018-05-12 09:13:12 -07:00
|
|
|
new-image blurred-layer-for-darker mask-size TRUE TRUE)
|
|
|
|
|
(set! blurred-layer-for-lighter
|
|
|
|
|
(car (gimp-layer-copy blurred-layer-for-darker TRUE)))
|
2011-03-01 23:55:43 -08:00
|
|
|
(gimp-image-insert-layer new-image original-layer-for-darker 0 -1)
|
2017-01-09 11:37:30 -08:00
|
|
|
(gimp-layer-set-mode original-layer-for-darker LAYER-MODE-SUBTRACT)
|
1998-04-09 05:32:04 -07:00
|
|
|
(set! darker-layer
|
2006-10-15 18:08:54 -07:00
|
|
|
(car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
|
2010-08-02 14:13:51 -07:00
|
|
|
(gimp-item-set-name darker-layer "darker mask")
|
|
|
|
|
(gimp-item-set-visible darker-layer FALSE)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
1998-04-09 05:32:04 -07:00
|
|
|
;; make lighter mask
|
2011-03-01 23:55:43 -08:00
|
|
|
(gimp-image-insert-layer new-image original-layer-for-lighter 0 -1)
|
2018-05-12 09:13:12 -07:00
|
|
|
(gimp-image-insert-layer new-image blurred-layer-for-lighter 0 -1)
|
|
|
|
|
(gimp-layer-set-mode blurred-layer-for-lighter LAYER-MODE-SUBTRACT)
|
1998-04-09 05:32:04 -07:00
|
|
|
(set! lighter-layer
|
2006-10-15 18:08:54 -07:00
|
|
|
(car (gimp-image-merge-visible-layers new-image CLIP-TO-IMAGE)))
|
2010-08-02 14:13:51 -07:00
|
|
|
(gimp-item-set-name lighter-layer "lighter mask")
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
1998-04-09 05:32:04 -07:00
|
|
|
;; combine them
|
2010-08-02 14:13:51 -07:00
|
|
|
(gimp-item-set-visible original-layer TRUE)
|
2017-01-09 11:37:30 -08:00
|
|
|
(gimp-layer-set-mode darker-layer LAYER-MODE-SUBTRACT)
|
1998-11-25 13:18:26 -08:00
|
|
|
(gimp-layer-set-opacity darker-layer mask-opacity)
|
2010-08-02 14:13:51 -07:00
|
|
|
(gimp-item-set-visible darker-layer TRUE)
|
2017-01-09 11:37:30 -08:00
|
|
|
(gimp-layer-set-mode lighter-layer LAYER-MODE-ADDITION)
|
1998-11-25 13:18:26 -08:00
|
|
|
(gimp-layer-set-opacity lighter-layer mask-opacity)
|
2010-08-02 14:13:51 -07:00
|
|
|
(gimp-item-set-visible lighter-layer TRUE)
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
|
1999-10-16 17:07:55 -07:00
|
|
|
(gimp-image-undo-enable new-image)
|
2006-10-15 18:08:54 -07:00
|
|
|
(gimp-displays-flush)
|
|
|
|
|
)
|
|
|
|
|
)
|
2004-11-18 14:44:28 -08:00
|
|
|
|
always return channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
2003-06-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.c (gimp_channel_bounds): always return
channel->x1,y1,x2,y2, *not* tx1,ty1,tx2,ty2 since the latter
contain bogus values if the mask is empty. Fixes bug #114419.
* plug-ins/script-fu/scripts/unsharp-mask.scm: cleaned up
while searching the bug.
2003-06-05 06:27:27 -07:00
|
|
|
(script-fu-register "script-fu-unsharp-mask"
|
2006-10-23 02:05:58 -07:00
|
|
|
"Unsharp Mask..."
|
|
|
|
|
"Make a new image from the current layer by applying the unsharp mask method"
|
2006-10-15 18:08:54 -07:00
|
|
|
"Shuji Narazaki <narazaki@gimp.org>"
|
|
|
|
|
"Shuji Narazaki"
|
|
|
|
|
"1997,1998"
|
|
|
|
|
""
|
2006-10-18 05:34:52 -07:00
|
|
|
SF-IMAGE "Image" 0
|
|
|
|
|
SF-DRAWABLE "Drawable to apply" 0
|
2006-10-20 10:55:14 -07:00
|
|
|
SF-ADJUSTMENT _"Mask size" '(5 1 100 1 1 0 1)
|
|
|
|
|
SF-ADJUSTMENT _"Mask opacity" '(50 0 100 1 1 0 1)
|
2006-10-15 18:08:54 -07:00
|
|
|
)
|