mapbox / spritezero

small opinionated sprites
Other
173 stars 63 forks source link

Return empty PNG and empty JSON if images array is empty #11

Closed jakepruitt closed 9 years ago

jakepruitt commented 9 years ago

Currently, passing an empty array into spritezero.generateImage throws an error (ref #10). The better behavior would be to return an empty PNG, possibly with an error that indicated that the image layout did not have any SVG's.

tmcw commented 9 years ago

Upstream in node-mapnik: mapnik.blend should accept zero-length arrays

jakepruitt commented 9 years ago

@tmcw any way we could change our usage of mapnik.blend to image.composite as described in #7?

@springmeyer or @flippmoke, are there specific reasons mapnik.blend throws an error for zero-length arrays?

tmcw commented 9 years ago

So! PNG images can't be 0x0. How about a blank response?

bsudekum commented 9 years ago

I don't think it makes sense to feed spritezero an empty array and expect it to respond with a valid (blank) png. It actually seems logical for spritezero to only work if the the array length > 0.

jfirebaugh commented 9 years ago

@bsudekum Why not? It simplifies all the downstream code and eliminates an unnecessary boundary condition.

bsudekum commented 9 years ago

this is done