Error: Could not find MIME for Buffer <null>
See original GitHub issueThis is the same as issue 643. However, the latter is closed and seems like it is dead despite people experiencing this issue still.
Expected Behavior
Jimp.read
loads an image from a URL correctly.
Current Behavior
Trying to read some images from certain URLs fails, throwing Error: Could not find MIME for Buffer <null>
Failure Information (for bugs)
Whilst certain images load correctly, other consistently fail (a failing url will always fail, without exception).
Example failing URL: https://s-media-cache-ak0.pinimg.com/736x/c9/8f/e1/c98fe17dc7de72bb29c34a0c79ef5762.jpg
Trying to Jimp.read
it 1000 times gives:
Called jimp.read() 1000 times.
Failed: 1000.
Succeeded: 0.
Steps to Reproduce
Repo with a simple script to reproduce the error: https://github.com/codan84/jimp-bug
Context
- Jimp Version: 0.6.4
- Operating System: OSX 10.14.3
- Node version: v10.16.2
Failure Logs
{ Error: Could not find MIME for Buffer <null>
at Jimp.parseBitmap (/Users/gruszd01/workspace/jimp-bug/node_modules/@jimp/core/dist/utils/image-bitmap.js:108:15)
at Jimp.parseBitmap (/Users/gruszd01/workspace/jimp-bug/node_modules/@jimp/core/dist/index.js:498:32)
at /Users/gruszd01/workspace/jimp-bug/node_modules/@jimp/core/dist/index.js:440:15
at /Users/gruszd01/workspace/jimp-bug/node_modules/@jimp/core/dist/index.js:168:14
at /Users/gruszd01/workspace/jimp-bug/node_modules/@jimp/core/dist/request.js:56:9
at IncomingMessage.<anonymous> (/Users/gruszd01/workspace/jimp-bug/node_modules/phin/lib/phin.compiled.js:1:2100)
at IncomingMessage.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19) methodName: 'constructor' }
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:28 (3 by maintainers)
Top Results From Across the Web
Could not find MIME for buffer (null) #643 - oliver-moran/jimp
I have this problem "Could not find MIME for buffer (null)" and i don't know how to fix it. I believe that the...
Read more >Error: Could not find MIME for Buffer <null> - Stack Overflow
I am doing the same course, and the problem is, that the sample picture (https://timedotcom.files.wordpress.com/2019/03/kitten-report.jpg) ...
Read more >LQIP generator error- Could not find MIME for Buffer
Hello, I have a website that is having an issue with LQIP. These are JPG and PNG images and when I check the...
Read more >Got “FAILURE Could not find MIME for Buffer <null>” error if ...
Got “FAILURE Could not find MIME for Buffer <null>” error if using the picture. Got success after using another fig.
Read more >Send picture telegram - NO USB CAMERA - Node-RED Forum
I know that we can do that with an usb camera but i want to do it another way. ... Error: Could not...
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 FreeTop 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
Top GitHub Comments
It’s also worth mentioning that reading the same image using an external request library (I used axios) into a buffer and then loading that same image to jimp from a buffer works.
An example of that is in
use-axios
branch of the repo I linked above.This would only mean that there’s an issue with whatever is used for http requests in jimp…
Not working:
Working:
This is happening when the image requested has a redirect response. Your sample image is returning this response: https://s-media-cache-ak0.pinimg.com/736x/c9/8f/e1/c98fe17dc7de72bb29c34a0c79ef5762.jpg
jimp does not handle this, neither does phin ❤️.1.0 Either upgrading the phin library ( #https://github.com/ethanent/phin/issues/20) or handling this in the jimp core ‘loadFromURL’ should do the trick.
For now, I updated this code in 'core/dist/index.js to solve my problem: