twolfson/spritesmith

Buffer support

tmcw opened this issue · 5 comments

tmcw commented

In order to support non-disk usage, spritesmith would need to support buffer input instead of filepaths.

Component PRs:

It doesn't look like phantomjs could support this, unfortunately, but the other 3 engines do it quite well.

At a glance, this sounds like a good idea. I have been wanted to increase performance from the output perspective by moving to streams but haven't gotten around to it.

How are we preserving original file names? The CSS needs to know where the original image was. Have you considered using gulp which supports buffers via its vinyl-fs system?

I found out how we want to preserve the file names after reading through some of the PRs. The current proposed format is use an object:

https://github.com/twolfson/spritesmith-engine-test/pull/2/files#diff-ece45662c2b2da9938c3abdbca204bbaR43

{id, buffer}

This seems fine from a first approach but I would prefer to use something more well formed like vinyl as mentioned earlier. Although, I would like to review other options/what other libraries do before choosing vinyl immediately. Thoughts?

https://github.com/wearefractal/vinyl

tmcw commented

Sorry - for my use case I ended up writing spritezero, which makes certain compromises for the specific need, and uses node-blend for compositing, which is much faster than canvas & comes with pre-compiled binaries - and tiletype for image sizing, which is pure-js and superquick.

That's great to hear. I wasn't confident in spritesmith's performance either. It is much more targeted at compatibility instead. I am going to leave this issue open since it is a feature I would like to eventullay support. However, I am going to close the PRs since we will probably use vinyl-fs or something similar. Thanks for your contributions =)

Ah, sorry. I totally forgot to close this issue and notify you when we added vinyl support =(