I'm writing a short Smart-Sharpen script. And it just stops without error message.
I'm hoping some kind soul can get the last two lines of code to execute:
CODING SUMMARY:1)
SmartSharpen_1() creates a rough edge mask from current layer. [AND WORKS FINE]
2)
{user manually cleans up any problems with the EDGE-MASK}
3)
SmartSharpen_2() uses layer EDGE-MASK for sharpening the layer directly below it with:
a) UNSHARP MASK
b) invert selection
c) GAUSSIAN BLUR
d) clear selection
Execution stops between 3b and 3c (without an error message).
I have included a summary up to the problem; and full code around the problem.
I can certainly upload the entire script if that helps.I have tried simplifying the code and throwing extra 'gimp.displays_flush()' as a "Hail Mary!".
I also tried running the Gaussian Blur manually. One time it worked; and the time I got 'GIMP Warning: The active layer is not visible."
But it was. Even via Python console showed the correct active layer and .visible=True
P.S.: is there a better forum for debug help?
def SmartSharpen_1(image, layer):
# Create a rough edge mask from current layer
# make copy of active layer; name it 'EDGE-MASK'; desaturate the EDGE-MASK:
# run EDGE-DETECT plugin on EDGE-MASK layer:
# run Color>Levels on EDGE-MASK layer.
# -----------------------------------------------------------------------------
# user should now manually clean up any problems with the EDGE-MASK; before running ....part2...
#------------------------------------------------------------------------------
def SmartSharpen_2(image, layer):
# use layer EDGE-MASK for sharpening the layer directly below it [since that is where 'SmartSharpen_1()' left the original photo]:
# create the channel 'EDGES'; copy layer 'EDGE-MASK' into channel 'EDGES'; copy 'EDGES' into {selection}; and hide 'EDGES':
# make 'EDGE-MASK' the active layer; delete 'EDGE-MASK'; which should make the original photo the active layer:
... code above removed for Brevity... full code below:
# make a copy of the original photo layer; do mods on the copy!; run UNSHARP plug-in; invert the selection; run GAUSSIAN plugin; clear the selection:
layer = image.active_layer.copy(True) #\ make a COPY OF original photo.
image.add_layer( layer, -1) #/
image.active_layer = layer # [i.e. work on a backup copy only]
pdb.gimp_selection_grow( image, 1)
pdb.plug_in_unsharp_mask( image, layer, 3.0, 0.65, 0)
pdb.gimp_selection_invert( image)
# --------------- execution stops here for some reason -------------------
pdb.plug_in_gauss_iir2( image, layer, 0.9, 0.9, 0)
pdb.gimp_selection_none( image)
image.undo_group_end()
pdb.gimp_displays_flush()