Gimp-Forum.net

Full Version: Lomo Effect for 2.9.9
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
I'm playing a bit with 2.9.9 and to train myself I started writing some very small filters.
This one is not ORIGINAL, i.e. has not been invented by me:  I took a couple of two small existing filters (in .scm), combined into just one and ported into python.
The original filters are:
- Alexia Death's script-fu-lomo-effect and Avi Bercovich's script-fu-lomo
Comments, critics, suggestions are welcome.
If someone is interested in the originals I attach here also those.
They are the versions I have in my folders, menu has been modified, they will appear under BestFilters/Photo/Effects (I do not remember the original menu).
My filter will appear under menu="<Image>/Diego/Ancillary2"
How is it different from the G'MIC Lomo effect ?
(03-11-2018, 01:23 PM)Espermaschine Wrote: [ -> ]How is it different from the G'MIC Lomo effect ?

A comparison in my Gimp 2.9.9, 
[Image: zPdpuG6.jpg]

edit: Ran the plugin again with the compat-mode switch off.
No errors, so future proof until the Gimp developers throw in some more weird code.
(03-11-2018, 01:00 PM)dinasset Wrote: [ -> ]Hi.
I'm playing a bit with 2.9.9 and to train myself I started writing some very small filters.
This one is not ORIGINAL, i.e. has not been invented by me:  I took a couple of two small existing filters (in .scm), combined into just one and ported into python.
The original filters are:
- Alexia Death's script-fu-lomo-effect and Avi Bercovich's script-fu-lomo
Comments, critics, suggestions are welcome.
If someone is interested in the originals I attach here also those.
They are the versions I have in my folders, menu has been modified, they will appear under BestFilters/Photo/Effects (I do not remember the original menu).
My filter will appear under menu="<Image>/Diego/Ancillary2"

**cough**

Code:
    pdb.gimp_context_push()
    currFG = pdb.gimp_context_get_foreground()
    currBG = pdb.gimp_context_get_background()

# [... snip ...]

    pdb.gimp_context_pop()
    pdb.gimp_context_set_foreground(currFG)
    pdb.gimp_context_set_background(currBG)

Context push/op operations are designed precisely to avoid saving/restoring colors and other context elements (pattern, font, gradient...)

Otherwise, what is specific to 2.9.x in the code?
Nothing specific, just the way to set the layer's mode is typical of 2.9

About the FG/BG saving/restoring: some times ago I noticed (on 2.8) that the push/pop operations were not enough for them (OK for pattern, font, gradient), hence I specifically added those.
Didn't try yet if that was a temporary bug on 2.8.
(03-12-2018, 05:13 AM)dinasset Wrote: [ -> ]Nothing specific, just the way to set the layer's mode is typical of 2.9

About the FG/BG saving/restoring: some times ago I noticed (on 2.8) that the push/pop operations were not enough for them (OK for pattern, font, gradient), hence I specifically added those.
Didn't try yet if that was a temporary bug on 2.8.

Works for me on 2.8.22. Even better, it seems that of you do one context_push() there is an implicit context_pop() at the end:

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from gimpfu import *

def testContext(image,layer):
    gimp.context_push()
    gimp.set_foreground(0,0,255)
    layer.fill(FOREGROUND_FILL)
#    gimp.context_pop()  # doesn't even seem necessary
    
register(
    'test-context','Test context','Test context',
    '','','','Test context','RGB*',
    [(PF_IMAGE,'image','Input image', None),(PF_DRAWABLE,'layer','Input layer', None)],[],
    testContext,
    menu='<Image>/Test'
)

main()
Very good info !