.gpl Palette to Image (Plugin/Script?) - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +--- Thread: .gpl Palette to Image (Plugin/Script?) (/Thread-gpl-Palette-to-Image-Plugin-Script) |
.gpl Palette to Image (Plugin/Script?) - P-Tux7 - 12-11-2020 My version: GIMP 2.10.18 Hello, I am asking if anyone has a plugin or script that can do the following: taking a palette (.gpl) and converting it to an image, with one pixel of each color that the palette has. For example, let's take the input as the Cool Colors palette included with GIMP The end result after inputting the Cool Colors.gpl in the plugin/script would be this (very tiny 8x1 image): I do not care if it writes the new image to the canvas, or outputs it as a file. I also do not care whether the colors are in order vertically or horizontally, and the "Number of Columns" in the .gpl can be discarded as well. The reason I need it is because I posterized a RGB 16-million color space image to levels of 32 red, 64 green, and 4 blue (based on the amount of receptors in the human eye for each color) in Paint.NET. And now I would like to have only the unique colors from it in an image, so I can further reduce that image's amount of colors using GIMP or GrafX2 to make a limited color palette for things like pixel art/game art. For example, I already did this with the Natural Colour System's 1952-color palette. (and if you ask how I got all those colors into an image, it was using the eyedropper on 1952 color swatches!!! But my new .gpl has 8192 colors, over 4 times as much. That's the reason I'm asking for an automation) https://lospec.com/palette-list/natural-colour-system-16 Here is the .gpl file of my new 8192-color palette if anyone wants to use it as a lab rat if they thankfully write the plugin/script https://cdn.discordapp.com/attachments/499070278366789632/786822757299519518/rgb-32-64-4.gpl RE: .gpl Palette to Image (Plugin/Script?) - carmen - 12-11-2020 This plugin ofn-colormap-to-layer should do the trick. - Downloaded from https://sourceforge.net/projects/gimp-tools/files/scripts/ - The zip includes short documentation on usage RE: .gpl Palette to Image (Plugin/Script?) - rich2005 - 12-11-2020 Unfortunately Ofnuts plugin is for indexed colour maps - 256 colours max ? I get an error from your monster palette ref. https://cdn.discordapp.com/attachments/499070278366789632/786822757299519518/rgb-32-64-4.gpl Can't try it out. Nothing straightforward that I can find. There might be a dedicated Gimp plugin around, can't find one. Easier in linux than Windows. You need Python installed to run this script. https://gist.github.com/mePy2/bb2f6f63af3f352378574ad1231555f5 And other scripts / plugins used as well Goes like this Extract the palette to text using Gimp. https://i.imgur.com/YtkDh6g.jpg The python script uses the default text file name. Looks like this: https://i.imgur.com/6MJ5UfR.jpg That produces a 1 pix x number of colours png file Put in some spaced guides ( I use a script for this) Split into layers using the guides (I use a plugin for this) Resize the canvas size to suit Space the layers out using the align tool. RE: .gpl Palette to Image (Plugin/Script?) - P-Tux7 - 12-12-2020 (12-11-2020, 12:17 PM)rich2005 Wrote: Unfortunately Ofnuts plugin is for indexed colour maps - 256 colours max ?Does this mean to put the .py file and palette.txt in the same folder? Also, I assume from the GitHub account's name that this script is meant to be used for Python 2? RE: .gpl Palette to Image (Plugin/Script?) - rich2005 - 12-12-2020 Quote: Does this mean to put the .py file and palette.txt in the same folder? Also, I assume from the GitHub account's name that this script is meant to be used for Python 2? I assumed python 2.7 Everything in one folder, that is the easiest way, saves some long paths. A bit of spare time yesterday, so a try out in a Win10 (VM) to check that it works there. For anyone interested. First installed python from https://www.python.org/ftp/python/2.7.8/python-2.7.8.amd64.msi (all users, default location C:\Python27 ) Next PIL from https://pypi.python.org/packages/2.7/P/Pillow/Pillow-2.5.3.win-amd64-py2.7.exe Get a palette.txt file from Gimp script palette_generator.py and palette.txt in the python folder Run from there to generate palette.png screenshot: https://i.imgur.com/Kmec5yu.jpg RE: .gpl Palette to Image (Plugin/Script?) - barrubba - 04-09-2021 (12-12-2020, 09:04 AM)rich2005 Wrote:Quote: Does this mean to put the .py file and palette.txt in the same folder? Also, I assume from the GitHub account's name that this script is meant to be used for Python 2? How i can add colormap in batch to multiple image/layers ? i've tried BIMP but doesn't support Colormap plugin. After Colormap i have simply to output same set of images. Thank you RE: .gpl Palette to Image (Plugin/Script?) - Ofnuts - 04-09-2021 (04-09-2021, 09:06 PM)barrubba Wrote:(12-12-2020, 09:04 AM)rich2005 Wrote:Quote: Does this mean to put the .py file and palette.txt in the same folder? Also, I assume from the GitHub account's name that this script is meant to be used for Python 2? Possibly (untested)
RE: .gpl Palette to Image (Plugin/Script?) - barrubba - 04-10-2021 (04-09-2021, 10:44 PM)Ofnuts Wrote:(04-09-2021, 09:06 PM)barrubba Wrote:(12-12-2020, 09:04 AM)rich2005 Wrote: I assumed python 2.7 Everything in one folder, that is the easiest way, saves some long paths. Ofnut Reply! Great! There is a way to mantain filename when importing as layer? so i can export filename as well with your Export-layers thank you RE: .gpl Palette to Image (Plugin/Script?) - Ofnuts - 04-10-2021 (04-10-2021, 12:49 AM)barrubba Wrote:(04-09-2021, 10:44 PM)Ofnuts Wrote:(04-09-2021, 09:06 PM)barrubba Wrote: How i can add colormap in batch to multiple image/layers ? AFAIK the layer takes the name of the file it comes from. OEL has two possible values in the pattern ({name} and {rawName}) for this reason: the layer name may contain an extension (.jpg, .png) that you can to remove and replace by your own (.gif) so you likely want a name pattern like {name}.gif. RE: .gpl Palette to Image (Plugin/Script?) - barrubba - 04-20-2021 I'm trying to use your REPLACE-COLORMAP plugin but sure i'm missing some step. I index an image with a custom palette, then i select in right panel a new palette (that i want to reapply to the image) with same color numbers. I get this error: GIMP Errore Plug-in "ofn-replace-colormap.py" (C:\Users\rnode1\AppData\Roaming\GIMP\2.10\plug-ins\ofn-replace-colormap.py) attempted to install procedure "temp-procedure-number-8" with invalid parameter name "num colors". GIMP Errore Errore di chiamata per la procedura "gimp-palette-get-colors": La procedura "gimp-palette-get-colors" è stata chiamata con il valore "(null)" l'argomento "name" (#1, tipo gchararray). Questo valore è fuori limite. What i'm wrong? |