jimp icon indicating copy to clipboard operation
jimp copied to clipboard

Share some examples of how to use it.(Multi page tiff from multiple images)

Open amitdixit opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. I need to create a single tiff from multiple images.(Multi pager). How can it be done.

Please share some examples. I have a directory with images and I want to generate a tiff.

The below is creating is merging the tiff file into one. but I want multi page each image with its own page.

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered const fs = require('fs'); const Jimp = require('jimp');

async function convertImagesToTiff(imagePaths, tiffOutputPath) { const images = [];

for (const imagePath of imagePaths) { const image = await Jimp.read(imagePath); images.push(image); }

// Combine images into a single TIFF image const combinedImage = await Jimp.create(images[0].bitmap.width, images[0].bitmap.height * images.length);

for (let i = 0; i < images.length; i++) { combinedImage.blit(images[i], 0, i * images[0].bitmap.height); }

// Save the combined image as a TIFF file await combinedImage.writeAsync(tiffOutputPath); console.log('TIFF file saved at:', tiffOutputPath); }

// Example usage const imagePaths = ['path/to/image1.png', 'path/to/image2.png']; const tiffOutputPath = 'output.tiff';

convertImagesToTiff(imagePaths, tiffOutputPath);

Additional context Add any other context or screenshots about the feature request here.

amitdixit avatar Jan 13 '24 09:01 amitdixit