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

Variant field in magic.json? #69

Open
NebularNerd opened this issue May 12, 2024 · 0 comments
Open

Variant field in magic.json? #69

NebularNerd opened this issue May 12, 2024 · 0 comments

Comments

@NebularNerd
Copy link
Contributor

Re-opening as #68 got a bit off-track from the original topic

Looking at #67 regarding imghdr I started looking at the SGI File format as that needs some love much like I did for PCX on #50. I was about to start on a PR to add all the variants but had an idea regarding naming convention.

At present the .json has a single name field, this works well enough but depending on how people use that name there could be a better way.

For example with PCX we now have:

["0a000101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, fixed EGA palette, 1bpp)"],
["0a020101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, modified EGA palette, 1bpp)"],
["0a030101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, 1bpp)"],
["0a040101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, 1bpp)"],
["0a050101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, 1bpp)"],
["0a000001", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, fixed EGA palette, no encoding, 1bpp)"],
["0a020001", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, modified EGA palette, no encoding, 1bpp)"],
["0a030001", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, no encoding, 1bpp)"],
["0a040001", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, no encoding, 1bpp)"],
["0a050001", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, no encoding, 1bpp)"],
["0a000102", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, fixed EGA palette, 2bpp)"],
["0a020102", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, modified EGA palette, 2bpp)"],
["0a030102", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, 2bpp)"],
["0a040102", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, 2bpp)"],
["0a050102", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, 2bpp)"],
["0a000002", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, fixed EGA palette, no encoding, 2bpp)"],
["0a020002", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, modified EGA palette, no encoding, 2bpp)"],
["0a030002", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, no encoding, 2bpp)"],
["0a040002", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, no encoding, 2bpp)"],
["0a050002", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, no encoding, 2bpp)"],
["0a030104", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, 4bpp)"],
["0a040104", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, 4bpp)"],
["0a050104", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, 4bpp)"],
["0a000004", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, fixed EGA palette, no encoding, 4bpp)"],
["0a020004", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, modified EGA palette, no encoding, 4bpp)"],
["0a030004", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, no encoding, 4bpp)"],
["0a040004", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, no encoding, 4bpp)"],
["0a050004", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, no encoding, 4bpp)"],
["0a030108", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, 8bpp)"],
["0a040108", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, 8bpp)"],
["0a050108", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, 8bpp)"],
["0a000008", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, fixed EGA palette, no encoding, 8bpp)"],
["0a020008", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.5, modified EGA palette, no encoding, 8bpp)"],
["0a030008", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (2.8, no encoding, 8bpp)"],
["0a040008", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (Paintbrush for Windows, no encoding, 8bpp)"],
["0a050008", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file (3.0, no encoding, 8bpp)"],

This is nice as we can determine every variant this format can offer, but maybe it's a bit too 'wordy'. A possible enhancement could be a 'variant' field in the .json like so:

    ["0a000101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file", "(2.5, fixed EGA palette, 1bpp)"],
    ["0a020101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file", "(2.5, modified EGA palette, 1bpp)"],
    ["0a030101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file", "(2.8, 1bpp)"],
    ["0a040101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file", "(Paintbrush for Windows, 1bpp)"],
    ["0a050101", 0, ".pcx", "image/x-pcx", "ZSOFT Paintbrush file", "(3.0, 1bpp)"],

etc...

This would give those who only need a basic name a straightforward 'this is what I am', while those who would like to know precisely could use the variant to get specifics.

Going back to the SGI format, we can see in the file specifications that it's got a small header with a lot of variant flags. At present there is one SGI entry in the .json at:

["01da01010003", 0, ".rgb", "image/x-rgb", "Silicon Graphics RGB Bitmap"],

Which equates to a RLE compression, 2bpc, multiple 2D images. I'm happy to run a PR with a similar naming convention as I did for PCX, this would generate a roughly similar length list for SGI variants, but had the idea and wanted to share.

Any thoughts on this?

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

No branches or pull requests

1 participant