jimp: Error: Could not find MIME for Buffer
This 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' }
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 33 (3 by maintainers)
Commits related to this issue
- Follow redirects Fixes #775 — committed to SaWey/jimp by SaWey 5 years ago
- Follow redirects (#789) * Follow redirects Fixes #775 * Follow redirects Fixing lint error * Follow redirects Fix tests * Added redirect test * Fixed lint errors * Skip redire... — committed to jimp-dev/jimp by SaWey 5 years ago
- Refactored the filterImageFromURL function in util.js to use axios to retrieve the image from the given URL. This buffers the image data which is then given in the input argument to the Jimp.read() fu... — committed to kathrynijones/aws-image-processing-microservice by kathrynijones 5 months ago
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-axiosbranch 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:
I’m also getting this issue, perhaps worth re-opening?
I also face this issue… Any news on this old issue?
I’m also seeing this “Error: Could not find MIME for Buffer <null>” error sporadically one time in about 5 or so. In my case, the images are local files (no network access involved). I’m working to extract a small test case from the larger test suite to submit for repro. Current versions of jimp 0.10.2 and node 13.12.0