After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 104639 - palette sorting and palette to gradient functionality
palette sorting and palette to gradient functionality
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Gimp-Python
git master
Other All
: Normal enhancement
: 2.4
Assigned To: Manish Singh
GIMP Bugs
Depends on: 351287
Blocks:
 
 
Reported: 2003-01-28 16:07 UTC by Carol
Modified: 2007-05-10 17:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sorts palettes many ways (8.27 KB, text/plain)
2003-01-28 16:09 UTC, Carol
Details
converts palettes to gradients (1.76 KB, text/plain)
2003-01-28 16:10 UTC, Carol
Details
palette sorting python-fu script (5.65 KB, application/x-python)
2006-05-16 15:06 UTC, Joao S. O. Bueno
Details
offsets the colors in a palette (2.61 KB, application/x-python)
2006-05-16 15:09 UTC, Joao S. O. Bueno
Details
fixed palette offset script (2.61 KB, text/x-python)
2006-05-16 16:17 UTC, Carol
Details
turns palettes into gradients (3.95 KB, text/x-python)
2006-05-16 16:25 UTC, Carol
Details
fixed offset script -- really! (2.71 KB, text/x-python)
2006-05-17 00:10 UTC, Carol
Details
palette to gradient, again (2.78 KB, text/x-python)
2006-05-17 00:11 UTC, Carol
Details
palette sorting script (5.24 KB, text/x-python)
2006-05-17 00:14 UTC, Carol
Details

Description Carol 2003-01-28 16:07:09 UTC
i use external scripts now for this.  it would be nice if The GIMP had a
button to push to do this and a pdb call as well.

http://adrian.gimp.org/sortpal/
Comment 1 Carol 2003-01-28 16:09:13 UTC
Created attachment 13887 [details]
sorts palettes many ways
Comment 2 Carol 2003-01-28 16:10:30 UTC
Created attachment 13888 [details]
converts palettes to gradients
Comment 3 Sven Neumann 2003-01-29 12:55:38 UTC
Not sure if this kind of functionality belongs into the core. Sounds
like it is perfectly well handled by a plug-in or script.
Comment 4 Kevin Ar18 2003-04-04 04:05:31 UTC
Putting it into the core would put the functionality more easily at 
your fingertips (so to speak).
Unless the concern here is bloat of the code.
Comment 5 Carol 2003-04-04 05:36:31 UTC
i think it would be useful to view the palettes sorted in different
ways, i think it could even be considered "editing".
Comment 6 Alan Horkan 2003-07-23 18:37:15 UTC
Changes at the request of Dave Neary on the developer mailing list.  
I am changing many of the bugzilla reports that have not specified a target
milestone to Future milestone.  Hope that is acceptable.  
Comment 7 Dave Neary 2003-11-25 12:57:57 UTC
Palette sorting has been added to the HEAD. User created palettes
cannot be sorted. Closing as fixed.

Dave.
Comment 8 Michael Natterer 2003-11-25 13:14:56 UTC
You can't just say "User created palettes cannot be sorted".
This request is asking for exactly this. Indexed palette
sorting is completely unrelated.
Comment 9 david gowers 2004-03-30 10:19:05 UTC
indexed palette sorting is not only unrelated, it's a regression from 1.2!
in 1.2, i could create palettes by making a image with the appropriate number of
pixels, and painting into it, then indexizing it and importing the palette from
the resultant image.
this depends on the palette remaining unsorted.

example (4x4 image == 16 colors)

0123
4567
89AB
CDEF

where hex number corresponds to the index of the color in that position,
assuming every pixel is a unique color. that was the behaviour, it's now broken.
i assume providing a checkbox to enable sorting is an appropriate solution.
i am looking into it.
Comment 10 Michael Natterer 2004-10-06 19:50:18 UTC
This can now be implemented in script-fu using the new gradient
and palette PDB APIs.
Comment 11 Sven Neumann 2004-10-22 18:35:09 UTC
It doesn't need to be on the 2.2 milestone then.
Comment 12 Sven Neumann 2005-07-26 15:12:44 UTC
Probably the thing that's missing here is a way for plug-ins/scripts register to
the Palette menu (and other such menus). This shouldn't be hard to add.
Comment 13 Michael Natterer 2006-05-16 13:56:20 UTC
Plug-ins can now register in the palette menu. Carol, do you want to
change these scripts to proper python or script-fu?
Comment 14 Joao S. O. Bueno 2006-05-16 15:06:38 UTC
Created attachment 65596 [details]
palette sorting python-fu script

Candidate for inclusion  - a single script that does palette sorting. Most of the script is taken by an RGB -> HSV conversion function because libgimpcolor was not available from python.
Comment 15 Joao S. O. Bueno 2006-05-16 15:09:26 UTC
Created attachment 65597 [details]
offsets the colors in a palette

This one is script realted to sorting: it offsets the colors inside a palette (palette rotate).

I have the palette->gradient scripts, but it needs some care. 
I've hit another bug here: when registering this second script to the <palettes> context menu it shows up disabled. Mitch said he'd take  a look
Comment 16 Carol 2006-05-16 16:17:11 UTC
Created attachment 65600 [details]
fixed palette offset script

Suspiciously simple repair made.
Comment 17 Carol 2006-05-16 16:25:27 UTC
Created attachment 65601 [details]
turns palettes into gradients

Python script that converts palettes to gradients.
Comment 18 Carol 2006-05-17 00:10:18 UTC
Created attachment 65623 [details]
fixed offset script -- really!

This fixes what I did earlier, a not enough coffee problem....
Comment 19 Carol 2006-05-17 00:11:51 UTC
Created attachment 65624 [details]
palette to gradient, again

Improved, I can't remember how....
Comment 20 Carol 2006-05-17 00:14:57 UTC
Created attachment 65625 [details]
palette sorting script

This script sorts palettes.

The original bug report was about palette sorting and palettes to gradients.  I was either too confused or too consistent....
Comment 21 Michael Natterer 2006-05-17 17:43:39 UTC
Added the scripts to CVS with some modifications. Leaving the bug
open for the reasons stated below:

2006-05-17  Michael Natterer  <mitch@gimp.org>

	* app/actions/plug-in-commands.c: moved the collection of plug-in
	args to a utilty function. Add another function that is called
	when the plug-in lives in <Brushes>, <Palettes> etc. and pass the
	active object's name to the plug-in.

	* plug-ins/pygimp/plug-ins/Makefile.am
	* plug-ins/pygimp/plug-ins/palette-offset.py
	* plug-ins/pygimp/plug-ins/palette-sort.py
	* plug-ins/pygimp/plug-ins/palette-to-gradient.py: added new
	scripts written by Joao S. O. Bueno Calligaris and fixed by Carol
	Spears. Changed them myself again. The stuff doesn't work as
	expected because python-fu has too much asumptions in its
	register() code, and the sort script doesn't implement all modes
	of Adrian's palette sorting perl script. Addresses bug #104639.
Comment 22 Sven Neumann 2006-08-15 16:55:38 UTC
Mitch, can you outline what needs to be done to fix the register() problems in pygimp? Perhaps open a separate bug report for this?
Comment 23 Sven Neumann 2006-08-18 09:45:17 UTC
I have done some changes to pygimp but the palette name is still not properly initialized from the value passed in the procedure call to the plug-in.

Pygimp does some mangling with the procedure arguments when the script is called, based on the menu location. This is rather ugly and it would become really ugly if we added special code for all the different registration points that are possible now. We should try to come up with a better solution.
Comment 24 Sven Neumann 2006-08-31 14:15:13 UTC
Would be nice to get some advice here from Yosh. Yosh, what do you think about the changes that I did to pygimp and what are your further plans for this?
Comment 25 Sven Neumann 2006-11-05 14:02:06 UTC
Would be nice if we could fix the remaining (hopefully small) issues and get this bug closed...
Comment 26 Manish Singh 2006-11-06 02:15:46 UTC
Hm, just to clarify, what do people expect here? I think since the script is invoked from the context menu of a given palette, the palette selection widget shouldn't be shown at all.

gimpfu should take the script-fu approach and examine the args at runtime to determine what parts of the UI should be shown. I'm not sure how this can be done generally, but relying on menu points is indeed broken.
Comment 27 Sven Neumann 2006-11-17 12:15:41 UTC
I agree that the palette selection widget should be suppressed when this parameter is passed to the script. I am also not sure how this can be done generally. Would it work if we only showed widgets for unspecified parameters?
Comment 28 Manish Singh 2007-05-10 17:07:33 UTC
Showing widgets only for unspecified parameters seems to work.

2007-05-10  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/gimpfu.py: remove parameter definition special
        casing that was based on menu and plugin types. Instead expect the
        script to specify all its parameters in its register call, and hide
        the UI elements for the parameters we are already passed in
        interactive mode. For compatibilty, this is only turned on when you
        specify the "menu" named argument in the register call, or if you pass
        an empty label. This should fix bug #104639.

        * plug-ins/pygimp/plug-ins/clothify.py
        * plug-ins/pygimp/plug-ins/colorxhtml.py
        * plug-ins/pygimp/plug-ins/foggify.py
        * plug-ins/pygimp/plug-ins/py-slice.py
        * plug-ins/pygimp/plug-ins/shadow_bevel.py
        * plug-ins/pygimp/plug-ins/whirlpinch.py: update to register image and
        drawable parameters explicitly.