anypalette.js
anypalette.js copied to clipboard
Files do not work in illustrator
Very odd the .ASE files work perfectly in Photoshop but not in Illustrator sadly. Is anyone else having this issue?
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:
Affinity Designer:
Illustrator:
InDesign:
Not really sure how to debug this error. But, if you have any ideas or other files, Iโd be glad to test them
In the meantime, I have confirmed these other libraries works in Adobe Illustrator and Adobe InDesign:
- https://github.com/DominikGuzei/node-ase-utils
- https://github.com/andywillis/rbg2ase
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.
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 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โ
- the first code block writes the bytes 'A','S','E','F',0,0,0,1, then
blocks.length
in big-endian. - the second code block writes the bytes 'A','S','E','F',0,1,0,0, then
blocks.length
in big-endian.
In fact, although GIMP supports the .ASE
format, files currently generated by Anypalette appear to cause GIMP to crash.
@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