Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color palette upload support #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Xpirix
Copy link
Collaborator

@Xpirix Xpirix commented Feb 12, 2025

Fix for #34

Changes summary

  • The style type Color Palette will be added automatically when a new .gpl file is uploaded
  • Added a validator to handle .gpl files
  • Get the palette name from the .gpl file
  • Add unit test

image

image

@Xpirix
Copy link
Collaborator Author

Xpirix commented Feb 12, 2025

Hi @dimasciput , it would be nice if you could review this. Thanks in advance.

@phidrho
Copy link

phidrho commented Feb 13, 2025

Hi @Xpirix,

thank you for implementation. You are very fast.

One concern that came to my mind is to do a check for encoding of a gpl file, since it is a txt file, and many text editors on windows save in local encoding (in my case Central European - Windows 1250 is default).

I am attaching additional files that you can use for testing purposes. I encoded one file in UTF-8 (this is how it should be by GPL specification, and another one that is encoded in Windows-1250. Test files include Croatian non-ascii letters - "Š" and "Č".
I'm not aware how can you easily determine if uploaded file is UTF-8 encoded, but there is probably some library that you can use that'll cover world-wide use cases.

GPL examples.zip

if not lines[1].strip().decode().startswith("Name:"):
raise ValidationError(_("Missing 'Name' in GPL file. Please ensure your file is correct."))

if not lines[2].strip().decode().startswith("Columns:"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Columns is optional by specification, and refers to GIMP specific use case:
From official specification:

Optional: if the next line starts with the prefix “Columns: ”, it must be followed by an integer between 0 and 255. This number will specify the number of columns to display the palette on. A value of 0 means that the number of columns will be variable, hence the display will be flowing with the interface size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants