1j01 / anypalette.js

๐ŸŽจ Read/write all color palette file formats โค๐Ÿงก๐Ÿ’›๐Ÿ’š๐Ÿ’™๐Ÿ’œ
https://1j01.github.io/anypalette.js/demo
MIT License
57 stars 8 forks source link

Files do not work in illustrator #14

Open someguy9 opened 1 year ago

someguy9 commented 1 year ago

Very odd the .ASE files work perfectly in Photoshop but not in Illustrator sadly. Is anyone else having this issue?

jlarmstrongiv commented 1 year ago

I have the same issue. I exported the sketch-default.sketchpalette as an .ase file from the demo. It opens perfectly in Adobe PhotoShop and Affinity Software, but is empty in Adobe Illustrator and errors in Adobe InDesign.

Photoshop:

image

Affinity Designer:

image

Illustrator:

image

InDesign:

image
jlarmstrongiv commented 1 year ago

Not really sure how to debug this error. But, if you have any ideas or other files, Iโ€™d be glad to test them

jlarmstrongiv commented 1 year ago

In the meantime, I have confirmed these other libraries works in Adobe Illustrator and Adobe InDesign:

peteroupc commented 1 month ago

I believe the code that writes to '.ASE' format is faulty:

https://github.com/1j01/anypalette.js/blob/eaf17cca78203bf2e68298137859f3f23cc46520/src/formats/Adobe.coffee#L328C2-L331C33

view.writeString("ASEF")
view.writeUint32(1) # version
view.writeUint32(blocks.length)

Which should probably be:

view.writeString("ASEF")
view.writeUint16(1) # version
view.writeUint16(0) # version
view.writeUint32(blocks.length)

This might not be the only issue with the '.ASE' writing code.

1j01 commented 1 month ago

One general strategy to test this would be to load a known-good .ASE file in anypalette.js and save it as .ASE and compare the files to see what's different. Of course this may be difficult since it's a binary format, and there may be many unimportant differences to address before any important difference is detected (depending on the complexity of the format). One could write a Kaitai Struct definition for ASE in order to help with this analysis. That in itself would be tedious, but maybe ChatGPT (or another LLM) can help with it, giving it a format specification document and/or parser source code to work off of. Edit: Wait, actually I already did this work! There are .ksy files in this repo, including for ASE.

Not saying this would be the best way to go about it. Might be easier to compare across library code, since @jlarmstrongiv pointed to some working libraries.

@peteroupc This strikes me as likely-equivalent code. It depends on the byte ordering, but the bit representation of 1 in Uint16 vs Uint32 is the same, right? Other than the number of 0 bits?

peteroupc commented 1 month ago

@peteroupc This strikes me as likely-equivalent code. It depends on the byte ordering, but the bit representation of 1 in Uint16 vs Uint32 is the same, right? Other than the number of 0 bits?

Assuming writeUint16 and writeUint32 are big-endian, as it appears to be—

In fact, although GIMP supports the .ASE format, files currently generated by Anypalette appear to cause GIMP to crash.

1j01 commented 1 month ago

@peteroupc You're right. This does seem to be a difference in the output of the anypalette.js compared to the palette files I have. I've updated the code to use writeUint16.

Does this new output work in Illustrator and InDesign? I confirmed it works in GIMP and that it crashes on the old output. I had to put it in a ZIP file to upload to GitHub: CSS3_named_colors.new-ase-output.zip