GNOME Bugzilla – Bug 104639
palette sorting and palette to gradient functionality
Last modified: 2007-05-10 17:07:33 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/
Created attachment 13887 [details] sorts palettes many ways
Created attachment 13888 [details] converts palettes to gradients
Not sure if this kind of functionality belongs into the core. Sounds like it is perfectly well handled by a plug-in or script.
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.
i think it would be useful to view the palettes sorted in different ways, i think it could even be considered "editing".
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.
Palette sorting has been added to the HEAD. User created palettes cannot be sorted. Closing as fixed. Dave.
You can't just say "User created palettes cannot be sorted". This request is asking for exactly this. Indexed palette sorting is completely unrelated.
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.
This can now be implemented in script-fu using the new gradient and palette PDB APIs.
It doesn't need to be on the 2.2 milestone then.
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.
Plug-ins can now register in the palette menu. Carol, do you want to change these scripts to proper python or script-fu?
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.
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
Created attachment 65600 [details] fixed palette offset script Suspiciously simple repair made.
Created attachment 65601 [details] turns palettes into gradients Python script that converts palettes to gradients.
Created attachment 65623 [details] fixed offset script -- really! This fixes what I did earlier, a not enough coffee problem....
Created attachment 65624 [details] palette to gradient, again Improved, I can't remember how....
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....
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.
Mitch, can you outline what needs to be done to fix the register() problems in pygimp? Perhaps open a separate bug report for this?
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.
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?
Would be nice if we could fix the remaining (hopefully small) issues and get this bug closed...
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.
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?
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.