strapi:vipsjpeg:输入文件错误的过早末端
问题:
从strapi(媒体库(UI))上传图像时,它向我显示了错误: vipsjpeg:输入文件的过早末端。
我试图将格式从JPG更改为PNG,但仍然显示出相同的错误。另一方面,我正在使用其他图像(JPG/PNG格式)进行测试。它正确上传。
我想知道错误的原因,以及是否有解决方案。 感谢您的答案
将图像上传到Strapi:媒体库
图像信息
- jpeg图像-19 kb
- 尺寸:750×938
error:
Error: VipsJpeg: Premature end of input file
config/plugins.js
default配置,提供的,提供由Strapi
module.exports = ({ env }) => ({
upload: {
config: {
breakpoints: {
xlarge: 1920,
large: 1000,
medium: 750,
small: 500,
xsmall: 64,
},
},
},
});
Problem:
When uploading an image from Strapi (the Media Library (UI)) it shows me the error: VipsJpeg: Premature end of input file.
I tried to change the format from jpg to png but it still shows the same error. On the other hand, I was testing with other images (jpg/png format). and it uploads correctly.
I would like to know the reason for the error, and if there is any solution.
I will appreciate your answer
Uploading image to strapi: Media Library
Image Info
- JPEG image - 19 KB
- Dimensions: 750 × 938
Error:
Error: VipsJpeg: Premature end of input file
config/plugins.js
Default configuration, provided by strapi
module.exports = ({ env }) => ({
upload: {
config: {
breakpoints: {
xlarge: 1920,
large: 1000,
medium: 750,
small: 500,
xsmall: 64,
},
},
},
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在遇到此问题时,这似乎是Sharp,Strapi Server停止的问题,因此它返回网络错误502。
要在我的代码中求解它,我必须扩展插件-UPLOAD代码并在该插件中更改此句子以停止导致服务器失败,然后图像可以成功上传,也许没有正确的优化但没有失败。
在node_module/@strapi/plugin-upload/server/services/image-manipulation.js上,将此句子更改
为
将其应用于strapi的步骤,将其应用于插件扩展名:
1-扩展插件-Uplopload插件,通过plugin-upload插件。在SRC/Extensions文件夹中创建(上传)文件夹(如果不存在,则创建扩展文件夹)
2-使用此内容创建一个名为(strapi-server.js)的文件,以覆盖image-manupilation服务:
3-复制(utils folder + services/image-manipulation.js),从node_module/@strapi/@strapi/plunin-plugin-upload/server复制到您的扩展文件夹。
4-如前所述,在Image -Manipulation.js中编辑变压器const。
有关尖锐问题的更多信息,请参阅此处: https://github.com/lovell/lovell/sharp/问题/1859
有关扩展Strapi插件的更多信息,请参见: https://docs.strapi.io/ddeveloper-docs/latest/development/plugins-extension.html
It Looks like this is an issue in sharp , Strapi server stop when it encounter this issue and because of that it return network error 502 .
to solve it in my code i had to extend the plugin-upload code and to change this const in that plugin to stop causing server to fail , then image can uploaded successfully , maybe without proper optimization but without failing .
on node_module/@strapi/plugin-upload/server/services/image-manipulation.js change this const
to this
Steps to Apply it to Strapi as plugin extension :
1 - extend the plugin-upload plugin by creating ( upload ) folder within src/extensions folder ( create extensions folder if it does not exist )
2 - Create a file named ( strapi-server.js ) with this content to overwrite the image-manupilation service :
3 - Copy ( utils folder + services/image-manipulation.js) from node_module/@strapi/plugin-upload/server to your extensions folder .
4 - Edit transformer const in image-manipulation.js as discussed before .
For more information about the sharp issue see here : https://github.com/lovell/sharp/issues/1859
For more information about Extending Strapi Plugin see here : https://docs.strapi.io/developer-docs/latest/development/plugins-extension.html