Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.gpl Palette to Image (Plugin/Script?)
#1
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
[Image: swVtA1G.png]

The end result after inputting the Cool Colors.gpl in the plugin/script would be this (very tiny 8x1 image):
[Image: lXZUwOI.png]

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-...-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/4...2-64-4.gpl
Reply
#2
This plugin ofn-colormap-to-layer should do the trick.
- Downloaded from https://sourceforge.net/projects/gimp-to...s/scripts/
- The zip includes short documentation on usage
Reply
#3
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/4...2-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/bb2f6f63af...d1231555f5

And other scripts / plugins used as well Wink 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.
Reply
#4
(12-11-2020, 12:17 PM)rich2005 Wrote: 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/4...2-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/bb2f6f63af...d1231555f5

And other scripts / plugins used as well Wink 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.
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?
Reply
#5
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/....amd64.msi (all users, default location C:\Python27 )
Next PIL from https://pypi.python.org/packages/2.7/P/P...-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
Reply


Forum Jump: