-
Notifications
You must be signed in to change notification settings - Fork 23
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
Error: Unsupported MIME type: #26
Comments
What's the file type of the file you tried to convert? |
This happens when the file you're trying to convert is in an unsupported format. |
I'm getting the same issue. I've had this problem before and I thought that was the reason for the addition of the -i flag. |
I'm also getting the same issue. -i the flag does not appear to make a difference. |
Could any of you create a minimal project to demonstrate the problem? And include the file you're trying to convert? Thanks |
I might have time later today, but here's the error I'm getting which may help.
Happens on any file that is not '.jpg' '.jpeg' or '.png' |
OK, cool. Are you trying to convert files like |
.gif mainly, (but also .pdf, .txt etc, to see if it would skip it) |
The underlying resizing library only seems to support jpg, png, and bmp. Looking at alternatives now. |
Thanks! .gif support would be ideal. |
If the file is not supported it will crash the app even if you put it inside a try catch handler. Even Sentry do not catch it. I had an image with a jpg extension but for some reason the mime type was image/vnd.adobe.photoshop instead of image/jpeg. and that image was crashing the app no matter what. The only way I was able to prevent the app from crashing is by removing the code: throw err; from line 46. This is a problem because if you allow users to upload files they will crash the app because the uploader will think they are uploading a jpg file. while the mime type might be something else. Maybe, instead of throwing the error, can we return a callback with the error as a parameter? |
I had this problem with unsupported file types (like docx, pdf, ai) and using the |
I ran into the same issue with a |
Cool, I'll take a look shortly. |
I just did this test with the latest master:
It seems to work properly, IMO. |
Thanks for checking @honza. Unfortunately I am still experiencing the mime type error with a JSON file on the latest release. Here is a pretty minimal test case that shows the problem: https://github.com/chrisdopuch/node-thumb-26-repro Just run
If you delete the JSON file in the images directory, then you don't hit the error. Let me know if I can help in any way, thanks for writing this useful tool 👍 |
Wow, thanks for the great reproduction case. This is super helpful. I had a look, and it looks like you're not using the latest code. The latest changes haven't been published to npm yet. I changed the package.json file like this, diff --git a/package.json b/package.json
index 61cae6c..0666649 100644
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
- "node-thumbnail": "^0.14.0"
+ "node-thumbnail": "git+https://[email protected]/honza/node-thumbnail.git"
},
"scripts": {
"start": "thumb --ignore images images" And then the latest master is installed. Then running the start command:
|
I just published |
Awesome! Confirmed working with my json files now. Thanks 👍 |
//app/node_modules/node-thumbnail/src/thumbnail.js:44
throw err;
^
Error: Unsupported MIME type:
at Jimp.throwError (//app/node_modules/jimp/index.js:82:43)
at Jimp.parseBitmap (//app/node_modules/jimp/index.js:307:31)
at //app/node_modules/jimp/index.js:200:29
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
Steps to reproduce:
Follow the readme.
The text was updated successfully, but these errors were encountered: