The file is incomplete. Could you give me an example image to test?
"Premature end of JPEG file" error.
Attempting to use Imagemin in a node module (RWI) and it's throwing the following error:
/Users/haydenbleasel/Projects/rwi/index.js:62 throw error; ^ Error: Premature end of JPEG file at Socket.<anonymous> (/Users/haydenbleasel/Projects/rwi/node_modules/imagemin/node_modules/imagemin-jpegtran/index.js:51:7) at Socket.emit (events.js:95:17) at Socket.<anonymous> (_stream_readable.js:764:14) at Socket.emit (events.js:92:17) at emitReadable_ (_stream_readable.js:426:10) at emitReadable (_stream_readable.js:422:5) at readableAddChunk (_stream_readable.js:165:9) at Socket.Readable.push (_stream_readable.js:127:10) at Pipe.onread (net.js:528:21) npm ERR! Test failed. See above for more details. npm ERR! not ok code 0 </anonymous></anonymous>
Occurs with every
.jpg image I give it. Also, using the latest dependencies and Node.js.
- 点赞 评论 复制链接分享
I did think so initially but as I mentioned, it happened with every .jpg that I tested. For example, this image from Unsplash.点赞 评论 复制链接分享
That image works fine for me running directly through imagemin (although it made it larger, lol). It's probably a problem somewhere in your code.点赞 评论 复制链接分享
Yep, that image breaks on my config. So assuming the image isn't actually corrupted, it's either a problem with my setup or perhaps a weird edge case in Imagemin. Any ideas on what to try?点赞 评论 复制链接分享
I would assume it's nothing wrong with your setup or imagemin (since it's working fine for me) but rather somewhere in the RWI code.点赞 评论 复制链接分享
Couldn't find any noticeable bugs in my code, so I created a bunch of basic square .jpg images for testing: 500px, 1000px, 1500px and 2000px. Only the 500px and 1000px ones worked without exploding. Seeing as the images that exploded are the 1500px and 2000px square images and the Unsplash image which are all fairly large images, I think it may be a case of file size. It does work on the CLI easily though, did you test using that?点赞 评论 复制链接分享
I tested both CLI and the programmatic way and both worked fine.点赞 评论 复制链接分享
So I figured out, due to my sheer stupidity, that in some cases I was reading and writing the same file. My guess is that the error didn't occur with smaller files due to some race condition. Still, might be something to note - I/O in the same folder can cause this error. Thanks for your help , appreciate it :)点赞 评论 复制链接分享
- golang os * File.Readdir在所有文件上使用lstat。 可以优化吗？
- PHP DOM DOCUMENT无法加载文件
- php数组中的.txt文件没有显示/ Apache 500错误
- memcache fast-cgi php apache 2.2 windows 7创建问题
- 当注销链接命中时，FOS UserBundle服务器错误
- java 发送post请求，内容为xml
- Deli Deli