-
-
Notifications
You must be signed in to change notification settings - Fork 760
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
get origin file size #22
Comments
Yes, you can get the width and height of an image like this:
You can also scale an image and keep its proportions like this:
|
Thanks, you rocks 👍 |
How do I get the original filename or url ex jimp.read('http://www.mysite.com/imgs/bugsbunny.png',function (err,img) { |
how do i process an array of images and return an array such as [{'url':'http://www.mysite.com/imgs/bugsbunny.png'},{'url':'http://www.mysite.com/imgs/daffyduck.png'}] |
@eservicesprovider Jimp does not store the original filename so that needs to be provided by some other means. The following code may be something like what you are asking for: const Jimp = require("jimp");
const imagePaths = [ // Here is an array of image paths to work on
'http://www.mysite.com/imgs/bugsbunny.png',
'http://www.mysite.com/imgs/daffyduck.png'
];
// Map imagePaths to Jimp.read Promises that return { url: path } after operating on image
// Promise.all executes all the Promise functions synchronously and returns an array of final results once all Promises are resolved
Promise.all(imagePaths.map(path => (
Jimp.read(path).then(img => {
// Do something to img
return { url: path };
})
))).then(urls => {
// You now have an array of urls:
// urls = [{url: 'http://www.mysite.com/imgs/bugsbunny.png'}, {url: 'http://www.mysite.com/imgs/daffyduck.png'}]
}); |
Hi
Is there a way to know the image size in entry?
I need it to do a resize without scale lose.
The text was updated successfully, but these errors were encountered: