It is currently Fri Apr 26, 2024 7:27 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: "with preview" module
PostPosted: Thu Jun 03, 2021 3:36 pm  (#1) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello, :)

Here is a "with preview" module (It's just a modification of "gimpfu.py").
It enables you to code "from fu_preview import *" in your python plug-ins to add a preview.
It's given with no warranties at all. It's just a "proof of concept".

Here is an example (the preview has been added to the "groove" plugin):
Attachment:
preview.jpg
preview.jpg [ 42.7 KiB | Viewed 8597 times ]

Installation:
  • uncompress the zip file
  • copy the "pymod.env" file into the "environ" directory
  • copy the "fu_preview.py" file into the "modules" directory

Use:
Replace the "from gimpfu import *" line by "from fu_preview import *"

Limitations:
  • only for python plugins using gimpfu
  • only for transformational plugins (not creation ones) that don't add new layers
  • for now, the preview only reacts to preview moves, slider moves, toggle changes
  • if you click "OK" (or "Cancel"?) before preview ends, you get error messages

I've tested it on Gimp 2.10 on Linux, on the "groove" plugin and on the "metalBox" plugin.

Enjoy!


Attachments:
fu_preview_v0.1.zip [8.63 KiB]
Downloaded 212 times

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: "with preview" module
PostPosted: Fri Jun 04, 2021 11:28 am  (#2) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
Hi Claude.

A great revelation. :yes

Tested with Win10_64bit Gimp-2.10.24.

First notes:
Put fu_preview.py in the "modules" directory - it doesn't work.
Placement in ... \lib\gimp\2.0\python\fu_preview.py - works.
Pymod.env seems redundant.???
Groove.py works fine with preview.
BoxEffect.py doesn't even register in the menu.
Trying to increase the preview by dragging will usually crash Gimp (but not always) - how to increase the preview window in fu_preview.py?


Attachments:
G1-big preview.jpg
G1-big preview.jpg [ 116.42 KiB | Viewed 8523 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: "with preview" module
PostPosted: Fri Jun 04, 2021 12:34 pm  (#3) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Thank you very much MareroQ for your valuable feedback, :tyspin

"pymod.env" enables to put "fu_preview" in "modules" directory ... on Linux.
Here is the content of "pymod.env":
: PYTHONPATH=${gimp_dir}/modules:${gimp_plug_in_dir}/python
I should have noticed that it's Linux syntax. :oops:
Maybe, ": PYTHONPATH=%gimp_dir%\modules:%gimp_plug_in_dir%\python" (or something like that) works on Windows ?

For "BoxEffect.py", I would run Gimp from a command line to check error messages.

Sorry, I cannot test on Windows.

"Trying to increase the preview ..." : I have to investigate.

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
 Post subject: Re: "with preview" module
PostPosted: Sat Jun 05, 2021 12:28 pm  (#4) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello, :)

I found an example of syntax for Windows in "default.env" and "pygimp.env" (in Windows Gimp installation)
PYTHONPATH=${gimp_installation_dir}\lib\gimp\2.0\python
and
; PYTHONPATH=${gimp_plug_in_dir}/python
So I guess a right syntax for Windows (to put in pymod.env) would be
; PYTHONPATH=${gimp_dir}/modules ; ${gimp_plug_in_dir}/python
or
; PYTHONPATH=${gimp_dir}\modules ; ${gimp_plug_in_dir}\python

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
 Post subject: Re: "with preview" module
PostPosted: Sat Jun 05, 2021 5:59 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
Is there any specific reason fu_preview.py is in "modules" (because it works without pymod.env in ...\lib\gimp\2.0\python \)?
"BoxEffect.py" does not give any error message in "console-message" mode (also not in pluginrc and with sys.stderr).

I did another test: renamed fu_preview.py to gimpfu.py and replaced the original gimpfu.py.
Result - BoxEffect.py works.
I also checked over a dozen other Python plugins - when do they use PF_TEXT, PF_COLOR, PF_PATTERN, PF_GRADIENT, PF_PALETTE ... ???... did not work.
So far this is a rather good solution for quick plugins as it increases (double?) The time (preview generating + generating output).

Edit:
By analyzing the last test from boxEffect.py, I discovered the cause.
In boxEffect.py, gimpfu appears twice (from gimpfu import * and from gimpfu import _query) - after changing gimpfu to fu_preview twice, the plugin works with preview.


Another solution (I tried it - it works) might be to add the code fu_preview.py to each plugin we want to preview (it's only 971 lines of code with a comment - and in Windows there is often a problem with multipart plugins).

Another point is completely different - groove.py needs to be upgraded for gmic-2.9.8. (different number of parameters for fx_curves_interactive).


Attachments:
Preview Metal_Box.jpg
Preview Metal_Box.jpg [ 103.86 KiB | Viewed 8422 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: "with preview" module
PostPosted: Sun Jun 06, 2021 10:47 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
A simple way to enlarge the preview window (without crashing Gimp):

1. Disable preview.
2. Drag the corner.
3. Turn on the preview again.

Example with embedded code for fu_preview (and customized fx_curves_interactive).
As with groove.py there was a problem with GMIC -fx_curves_interactive (but this is probably a temporary bug with the number of parameters in GMIC because running it gives an error).


Attachments:
bd1.jpg
bd1.jpg [ 202.52 KiB | Viewed 8340 times ]
bd2-GMIC.jpg
bd2-GMIC.jpg [ 163.13 KiB | Viewed 8340 times ]
bede2.10 with preview.zip [8.62 KiB]
Downloaded 164 times

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: "with preview" module
PostPosted: Tue Jun 08, 2021 2:31 pm  (#7) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello, :)

Thanks again, MareroQ, for your very good work. :tyspin

Quote:
Is there any specific reason fu_preview.py is in "modules"
I wanted that fu_preview.py won't be overwritten by a new version of Gimp.
(But, maybe, it's a bad idea since, in any case, fu_preview.py might not be compatible any more.)
Quote:
By analyzing the last test from boxEffect.py, I discovered the cause. [...] from gimpfu import _query
Yes, I forgot that I have add this line (I've tested a version without this line) :oops:
Quote:
PF_TEXT, PF_COLOR, PF_PATTERN, PF_GRADIENT, PF_PALETTE ... ???... did not work
You're right : for now, I only implemented PF_SLIDER and PF_TOGGLE.

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
 Post subject: Re: "with preview" module
PostPosted: Wed Jun 09, 2021 12:13 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
I keep my fingers crossed for further rapid development. ;)

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: "with preview" module
PostPosted: Fri Jun 11, 2021 10:46 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
I remembered (Ofnuts tip in another thread) how to enlarge the preview window on startup (without dragging the edges).
You need to edit the file gtkrc [... etc\gimp\2.0\gtkrc]

Replace the following lines:

style "gimp-large-preview"
{
  GimpPreview::size = 256
}

# class "GimpPreview" style "gimp-large-preview"


on:

style "gimp-large-preview"
{
  GimpPreview::size = 512
}

class "GimpPreview" style "gimp-large-preview"


Maybe there are other ways? :hoh


Attachments:
Big preview at startup .jpg
Big preview at startup .jpg [ 159.53 KiB | Viewed 8101 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: "with preview" module
PostPosted: Sun Jun 13, 2021 3:34 pm  (#10) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello, :)

Thanks, MareroQ, for the Ofnuts's tip.

Here is a new version of the "with preview" module:

New features:
I've made an implementation for PF_COLOR, PF_SPINNER, PF_FONT, PF_STRING, PF_FLOAT, PF_INT, PF_TEXT, PF_PATTERN, PF_OPTION, PF_GRADIENT (not tested), PF_PALETTE (not tested)

Installation:
  • uncompress the zip file
  • copy the right "pymod_blabla.env" file into the "environ" directory
  • copy the "fu_preview.py" file into the "modules" directory
If this doesn't work, put the "fu_preview.py" file into the same directory as "gimpfu.py".

Use:
Replace "gimpfu" by "fu_preview" in your plugin code.

Enjoy!


Attachments:
fu_preview_v0.1.1.zip [9.38 KiB]
Downloaded 166 times

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin
Top
 Post subject: Re: "with preview" module
PostPosted: Fri Jun 18, 2021 3:10 pm  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2247
Location: Poland
Many thanks for the new features. :jumpclap
I tested new functions - everything works. :yes

Two minor problems: :roll:
- There is a problem when you use the selection
preview (strange shift) - but the result is correct.
- In case of using alpha channel (transparency) it has to be added to the image before using any plugin.

Are You going to add the last missing ones (PF_BRUSH, PF_CHANNEL, PF_DIRNAME, PF_FILE, PF_FILENAME, PF_VECTORS)?


Attachments:
Tested New features.jpg
Tested New features.jpg [ 134.98 KiB | Viewed 3091 times ]
Invalid preview for selection2 .jpg
Invalid preview for selection2 .jpg [ 67.5 KiB | Viewed 3091 times ]
Invalid preview for selection .jpg
Invalid preview for selection .jpg [ 117.9 KiB | Viewed 3091 times ]

_________________
Image

Slava
Ukraini!
Top
 Post subject: Re: "with preview" module
PostPosted: Wed Jun 23, 2021 9:54 am  (#12) 
Offline
GimpChat Member

Joined: Apr 19, 2021
Posts: 121
Location: France
Hello, :)
Thanks, MareroQ, for your very valuable feedback. :tyspin

Quote:
There is a problem when you use the selection preview (strange shift)
I have not even thought about the possibility of making a selection before using a filter.
This problem seems more complex to fix.
Quote:
In case of using alpha channel (transparency) it has to be added to the image before using any plugin.
I don't understand. :?
Quote:
Are You going to add the last missing ones (PF_BRUSH, PF_CHANNEL, PF_DIRNAME, PF_FILE, PF_FILENAME, PF_VECTORS)?
I hope so. But, I would want to present a "GEGL graph" tutorial firstly.

_________________
Photo to cartoon : https://github.com/cl4cnam/gimp_cartoon_plugin


Top
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Brush does not look like Preview.

2

No new posts Attachment(s) Potrace with LIVE PREVIEW

0

No new posts Attachment(s) AutoTrace with LIVE PREVIEW

14

No new posts Attachment(s) Distort with LIVE PREVIEW

5

No new posts Attachment(s) Symetrize with LIVE PREVIEW

4



* Login  



Powered by phpBB3 © phpBB Group