I'd like to be able to join a collection of images into a single RGB image with sharp, as in vips bandjoin. I can think of two ways to go about this, but I think both of them are a little ugly.
- Overload the sharp constructor to accept an object or array containing image filenames or buffers to be joined before being processed:
sharp([image1, image2, image3]).xyz().toBuffer(...);
- Add a new function to sharp to join on more image bands / channels after the image has been loaded:
sharp(image1).joinChannel([image2, image3]).xyz().toBuffer(...);
The downside to method 1 is that it is not semantically clear what will happen with the array of images. This could be mitigated by putting them in an object with some descriptive key, such as {0:image1, 1:image2, 2:image3}. The downside to method 2 is that it spreads out the image bands where they should be logically grouped together. There's nothing special about image1 vs image2 and image3, except that it's supposed to end up in band 0.
Thoughts and suggestions? I plan to submit a pr for something like this, and I'm leaning towards method 1.
I'd like to be able to join a collection of images into a single RGB image with sharp, as in vips
bandjoin. I can think of two ways to go about this, but I think both of them are a little ugly.The downside to method 1 is that it is not semantically clear what will happen with the array of images. This could be mitigated by putting them in an object with some descriptive key, such as
{0:image1, 1:image2, 2:image3}. The downside to method 2 is that it spreads out the image bands where they should be logically grouped together. There's nothing special about image1 vs image2 and image3, except that it's supposed to end up in band 0.Thoughts and suggestions? I plan to submit a pr for something like this, and I'm leaning towards method 1.