Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amitdixit opened this issue Jan 13, 2024 · 0 comments
Labels
documentation Changes only affect the documentation

Comments

@amitdixit
Copy link

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.

@hipstersmoothie hipstersmoothie added the documentation Changes only affect the documentation label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Changes only affect the documentation
Projects
None yet
Development

No branches or pull requests

2 participants