A Swift command-line tool to convert GIMP .gpl
palette files to macOS .clr
color palette files.
Includes an option to install the generated .clr
file to the macOS ~/Library/Colors
directory so that they show up in the user's colour picker (in the drop-down list on the Colour Palettes tab).
I wanted to be able to use a set of brand colours in my macOS apps. I had the colour information in hex format, and this was simple to put into a Gimp palette file which is a plain text format. Apple macOS colour palette files are binary; the Python options I found for manipulating them didn't work as I wanted, so I whipped this up using Swift.
It does the job; I later discovered another existing tool to do something similar. YMMV.
- Parse GIMP
.gpl
palette files. - Generate
.clr
color palette files for macOS. - Install palettes to
~/Library/Colors
. - Optional dry-run mode for testing without creating files.
-
Clone the repository:
git clone https://github.com/andypiepr/gpl2clr.git cd gpl2clr
-
Compile using Swift:
swiftc GeneratePalette.swift -o gpl2clr
-
Move the executable to a directory in your
PATH
for easy use:mv gpl2clr /usr/local/bin
The tool can also be run directly without being compiled:
swiftc GeneratePalette.swift [options]
gpl2clr <gpl-file-path> [<clr-file-path>] [--install] [--verbose] [--dry-run]
<gpl-file-path>
: Path to the input.gpl
file (required).<clr-file-path>
: Optional path to save the.clr
file. Defaults to input path with.clr
suffix.--install
: Installs the.clr
file to~/Library/Colors
.--dry-run
: Checks the conversion process without creating or installing files.--verbose
: Outputs detailed parsing logs.--help
: Displays the help message.
gpl2clr GNOME_HIG.gpl GNOME.clr
gpl2clr GNOME_HIG.gpl --install
gpl2clr GNOME_HIG.gpl --dry-run
gpl2clr GNOME_HIG.gpl GNOME_HIG.clr --verbose
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.