Closed txtl closed 3 years ago
I'm not following your use case. Can you rephrase what your setup is and what you're trying to do?
For example, I have a workflow to convert a proprietary image format, represented by a name, to SVG and then PNG to generate the sprite sheet. During the workflow, we need to store the PNP images in a directory to use with this library. The JSON file generated by spritesmit uses the file names including the path as the keys for each frame, while our workflow needs to use the original name as the key to extracting the images from the sprite sheet because the frontend codes do not know the directory where the PNG files were stored. That's why we need to strip off the directory path and the extension to get the original name of the image.
Basically, it's a feature that TextTure Packer or Free Texture Packer supports, which I think is useful in many cases.
Thanks,
Okay, to paraphrase: you want to read in images files but change the filepath the result.coordinates
references
spritesmith
doesn't save any files to disk so any manipulation can be done before/after spritesmith
for that scrubbing
Here are 2 ways to accomplish it:
vinyl-fs
to read in files but then override what the actual filename is -- this will alter what is fed into spritesmith.run
/spritesmith.createImages
Object.keys(result.coordinates).forEach((coordinateKey) => { ... })
)
It'd be great if there's an option to remove the directory path and file extension in the JSON file. I modified it for my purpose, but it'd be great to have that option in the official release so that I don't have to maintain it in a fork branch.
https://github.com/twolfson/spritesmith/blob/03f5c3514d502296f645dfcafdec41c220eaef77/src/smith.js#L155
.....
Thanks,