Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIMP palette file (.gpl) format / syntax?

Tags:

palette

gimp

I'm looking for the exact specifications of this file format. Anyone got a link? Or want to comment?

I have spent the better part of the day searching, yet I keep getting directed back to the GIMP online user-manual. It says "look at a .gpl file and you will see it is easy" to build manually with a text editor. I don't actually have GIMP, but I see examples online. Yep, easy. • EXCEPT:

• What meaning do the color names ultimately have? Are they purely semantic, or does a program rely on them? If the latter, then what if there are two (2) or more colors with the same name?

• What does the "Columns" line do? I've seen examples that have no "Columns" line. I've seen examples that have values of 0, 4, and 16; yet this does not in any way that I can see correspond to the color data. I see 3 columns of decimal-sRGB values, and an optional 4th column with the color-name; seems I remember the example with "Columns 4" had no color names, only the 3 RGB columns.

• Do columns of RGB values need to "line up"? Or will the following example from my output algorithm work? (from the Crayola palette):

159 129 112 Beaver
253 124 110 Bittersweet
0 0 0 Black
172 229 238 Blizzard Blue
31 117 254 Blue
162 162 208 Blue Bell
102 153 204 Blue Gray
13 152 186 Blue Green

• Does this format accept sRGBA colors? And if so, how is the "A" value defined (0-1, 0%-100%, 0-127, 0-255, etc.?) (seems I remember when creating .png files with PHP, the "A" value was 7-bit)?

• How exactly do you add comments / metadata? Today I see an example that says lines that begin with # are comments, or anything after a # on a line is a comment. Yesterday I thought (maybe I'm confused) I saw an example that said that comment lines begin with ;

• Is any other data-format supported? Originally I thought the text-line just before the color-data that I see in every example indicated the format: "#" signifying decimal-sRGB; until today when I see that is just a blank-line comment.

• What line ending character(s) can / must I use? \n \r

• What character-encodings can I use? ASCII only? ¿UTF-8 ☺ with extended ♪♫ charset (¡hopefully!)?

• Anything I'm missing? Any other options available?

Here is an example from http://gimpchat.com/viewtopic.php?f=8&t=3375#

GIMP Palette
Name: bugslife_final.png-10
Columns: 16
#
191 180 180   Index 0
163 158 157   Index 1
145 136 132   Index 2
130 125 112   Index 3
… … …
56  50  49   Index 29
41  38  38   Index 30
23  23  23   Index 31
242 245 213   Index 32
227 232 181   Index 33
210 217 147   Index 34
195 204 118   Index 35
… … …
  0   0   0   Index 251
  0   0   0   Index 252
  0   0   0   Index 253
  0   0   0   Index 254
  0   0   0   Index 255

Aloha!

like image 464
SoftMoon WebWare Avatar asked Mar 29 '20 15:03

SoftMoon WebWare


People also ask

What is a .GPL file?

A GPL file is a color palette created for use in GIMP or another image editing program. It contains settings that allow you to quickly load and select from a group of related colors while editing an image.

How do I import palette into GIMP?

Import the Palette in GIMP If you haven't already, open GIMP. In the top menu, select Windows > Dockable Dialogs > Palettes to open the palette settings on GIMP. Now, right-click in the Palettes dialog, and choose Import Palette... from the resulting menu. GIMP will open a new window for you to control your import.

Where are GIMP palettes saved?

When you create palettes using the Palette Editor, they are automatically saved as soon as you exit GIMP , in the palettes folder of your personal GIMP directory.


1 Answers

Looking at the source code:

  • Columns is just an indication for display in the palette editor
  • Comments must start with a #. In non-empty lines that don't, the first three tokens are parsed as numbers
  • There is no alpha support
like image 57
xenoid Avatar answered Oct 23 '22 23:10

xenoid