This repository has been archived by the owner on Feb 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Return actual image dimensions #89
Comments
Dupe of #38? |
Yes except I only care about width and height and provided an efficient solution 😄 |
Probably blocked on #48; "Add Redis caching" |
Actually, that fastimage module is pretty awesome. There is one "gotcha" with it though, you need to set const fs = require('fs');
const { getMetadata, getRecommendations } = require('proxy-services');
const fastimage = require('fastimage');
fastimage.threshold(-1);
getRecommendations()
.then((urls) => getMetadata(urls))
.then((metadata) => {
fs.writeFileSync('metadata.json', JSON.stringify(metadata, null, 2));
return metadata;
})
.then((metadata) => {
return Object.keys(metadata).map((url) => {
const result = metadata[url];
if (result.images[0]) {
return fastimage.info(result.images[0].url)
.then(({width, height, url}) => {
// Overwrite the bogus width/height with the returned values.
result.images[0].width = width;
result.images[0].height = height;
return result;
});
}
return result;
});
})
.then((promises) => Promise.all(promises))
.then((result) => console.log(JSON.stringify(result, null, 2)))
.catch((err) => console.error(err));
|
jaredlockhart
added a commit
that referenced
this issue
Sep 8, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 21, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 28, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 29, 2016
jaredlockhart
added a commit
that referenced
this issue
Sep 29, 2016
Return actual image dimensions fixes #89
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I noticed that real image dimensions aren't being returned. Having the image dimensions is super helpful to make sure placeholders are the right size and to do custom layouts based on the size of the images.
Here's a cool lib that could make this easy/efficient: https://github.com/ShogunPanda/fastimage
The text was updated successfully, but these errors were encountered: