Get image width and height from stream
See original GitHub issueHi! Thanks for an excellent module!
I’m trying to read image width and height from a stream, but nothing happens.
In the code below nothing is printed to console.
If I remove .pipe(metaReader)
the response is printed etc.
What am I missing?
const request = require('request')
const sharp = require('sharp')
let image
const metaReader = sharp()
.on('info', info => {
image = info
})
.on('error', err => {
console.log(err)
})
request
.get('https://images-na.ssl-images-amazon.com/images/M/MV5BMTUyMjM2NTgwNl5BMl5BanBnXkFtZTgwMTUzOTUwMjI@._V1_SX1777_CR0,0,1777,999_AL_.jpg')
.pipe(metaReader)
.on('response', function(response) {
console.log(response) // 200
})
.on('error', err => {
console.log(err)
})
.on('end', () => {
console.log('end')
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
how can I get image size (w x h) using Stream - Stack Overflow
First you have to write the image: System.Drawing.Image image = System.Drawing.Image.FromStream (new System.IO.MemoryStream(byteArrayHere));.
Read more >Width and height of image from byte array C# - MSDN - Microsoft
Best way to get width and height is convert bytes first to image and read from that. For example following code creates Stream...
Read more >C# aspose : how to get width/height of an image/stream to do ...
Here is the code how to get image width/height with .NET System.Drawing : Image image = Image.FromStream(stream); Console.WriteLine($"{image ...
Read more >How to find width and height of an image using Python?
In order to find the height and width of an image, there are two approaches. The first approach is by using the PIL(Pillow)...
Read more >getimagesize - Manual - PHP
The getimagesize() function will determine the size of any supported given image file and return the dimensions along with the file type and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’ll need to tell
metaReader
what to do. If you’re expecting metadata about the input image then try something like (untested):Sorry, missed your question (too many GH notifications)… you should be able to get away with passing a truncated Buffer with only the header to read image dimensions, but watch out for things like large ICC profiles that can be part of the header. Hope this helps.