I would like to create an image from an array of image buffers with x number of images per row.
Hello, this isn't supported at the moment, but could make a future possible enhancement.
I recommend spawning a vips child process to do this right now - see https://github.com/lovell/sharp/issues/1175#issuecomment-377678250
The general use case for image stitching suggests this could be exposed via a utility function that would provide a "join" operation/pipeline only so e.g. no resizing at the same time.
馃憞 PROPOSED API, NOT YET IMPLEMENTED OR AVAILABLE
sharp
.join([
[image1, image2],
[image3, image4]
], {
background: '#fff',
halign: 'centre',
shim: 10
})
.toBuffer()
.then( ... )
鈽濓笍 PROPOSED API, NOT YET IMPLEMENTED OR AVAILABLE
...where image1 are either filenames or Buffer objects (no Streams). Note also that a 2D array should probably be passed in (to be flattened internally to the 1D array expected by vips_arrayjoin.
Is there a way to use the bundled libvips from the child process? https://github.com/lovell/sharp/issues/1175#issuecomment-379417216
for .join() would it be possible to pass a 2d array that gets split up if there鈥檚 a across parameter. I think vips_arrayjoin() already has an across parameter
Is there a way to use the bundled libvips from the child process?
Only shared libraries are included, no executable files.
How do you use a child process
const { execFileSync } = require('child_process');
function combine(images){
const child = execFileSync('vips', ['arrayjoin', images, '--across 8', 'output.jpg']);
}
images is "img-0.jpg img-1.jpg img-2.jpg img-3.jpg img-4.jpg img-5.jpg img-6.jpg img-7.jpg img-8.jpg img-9.jpg img-10.jpg img-11.jpg img-12.jpg img-13.jpg img-14.jpg img-15.jpg img-16.jpg img-17.jpg img-18.jpg img-19.jpg img-20.jpg img-21.jpg img-22.jpg img-23.jpg img-24.jpg img-25.jpg img-26.jpg img-27.jpg img-28.jpg img-29.jpg img-30.jpg img-31.jpg img-32.jpg img-33.jpg img-34.jpg img-35.jpg img-36.jpg img-37.jpg img-38.jpg img-39.jpg img-40.jpg img-41.jpg img-42.jpg img-43.jpg img-44.jpg img-45.jpg img-46.jpg img-47.jpg"
But when I run it i get Unknown option --across 8 however if I run vips arrayjoin "img-0.jpg img-1.jpg img-2.jpg img-3.jpg img-4.jpg img-5.jpg img-6.jpg img-7.jpg img-8.jpg img-9.jpg img-10.jpg img-11.jpg img-12.jpg img-13.jpg img-14.jpg img-15.jpg img-16.jpg img-17.jpg img-18.jpg img-19.jpg img-20.jpg img-21.jpg img-22.jpg img-23.jpg img-24.jpg img-25.jpg img-26.jpg img-27.jpg img-28.jpg img-29.jpg img-30.jpg img-31.jpg img-32.jpg img-33.jpg img-34.jpg img-35.jpg img-36.jpg img-37.jpg img-38.jpg img-39.jpg img-40.jpg img-41.jpg img-42.jpg img-43.jpg img-44.jpg img-45.jpg img-46.jpg img-47.jpg" --across 8 output.jpg from the project directory in cmd it works and creates the output.jpg file
I think you need to specify --across and 8 as separate arguments. This is a Node thing unrelated to sharp or libvips.
@lovell Is this still planned? Would be very useful!
@willemmulder PRs are always welcome, if you're able.
@lovell Not just yet, unfortunately. I'm just getting started, and looking for a way to stitch together a bunch of smaller images. I previously implemented things in jimp but now started to look into Sharp because jimp was so memory-hungry (using >2GB for stitching 196 small images).
@lovell Is there a way in Sharp to make raw calls to libvips? So I could call the arrayjoin function through Sharp?
Most helpful comment
Hello, this isn't supported at the moment, but could make a future possible enhancement.
I recommend spawning a
vipschild process to do this right now - see https://github.com/lovell/sharp/issues/1175#issuecomment-377678250The general use case for image stitching suggests this could be exposed via a utility function that would provide a "join" operation/pipeline only so e.g. no resizing at the same time.
馃憞 PROPOSED API, NOT YET IMPLEMENTED OR AVAILABLE
鈽濓笍 PROPOSED API, NOT YET IMPLEMENTED OR AVAILABLE
...where
image1are either filenames or Buffer objects (no Streams). Note also that a 2D array should probably be passed in (to be flattened internally to the 1D array expected byvips_arrayjoin.