bash ImageMagick:此图像格式没有解码委托`'@ error/constitute.c/ReadImage/504

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37594157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:19:16  来源:igfitidea点击:

ImageMagick: No decode delegate for this image format `' @ error/constitute.c/ReadImage/504

imagebashmacosimagemagickimagemagick-convert

提问by Montag

Problem:ImageMagick convert is unable to crop image. It looks like it doesn't recognize the image type?

问题:ImageMagick convert 无法裁剪图像。看起来它无法识别图像类型?

What I've Tried:

我试过的:

I've searched around online and I've seen several similar issues but not mine. I've attempted their solutions including

我在网上搜索过,我看到了几个类似的问题,但不是我的。我尝试过他们的解决方案,包括

  • Uninstalling and reinstalling ImageMagick via brew.
  • identify -list format (JPEG, GIF, PNG, TIFF, etc were all there and all had rw permissions)
  • convert -version (png is is among the built-in delegates)
  • convert pic1.png pic1-jpg.jpg (this worked fine)
  • convert pic1-jpg.jpg pic1-jpg.jpg (this worked fine)
  • convert pic1-jpg.jpg 805X972+34+94 pic1-jpg-crop.jpg (this gave the same error as for png as shown below)
  • 通过 brew 卸载并重新安装 ImageMagick。
  • 识别 -list 格式(JPEG、GIF、PNG、TIFF 等都在那里并且都有 rw 权限)
  • convert -version (png 是内置委托之一)
  • 转换 pic1.png pic1-jpg.jpg (这工作正常)
  • 转换 pic1-jpg.jpg pic1-jpg.jpg (这工作正常)
  • 转换 pic1-jpg.jpg 805X972+34+94 pic1-jpg-crop.jpg (这给出了与 png 相同的错误,如下所示)

 

 

I'm working on Mac OSX El Capitan and everything else in terminal works fine. ImageMagick was already installed.

我正在 Mac OSX El Capitan 上工作,终端中的其他一切工作正常。ImageMagick 已经安装。

When I run:

当我运行时:

$ convert /Users/Innovate/Desktop/crop/2015-04-26-GinaDate13_487.png 805X972+34+94 /Users/Innovate/Desktop/crop/2015-04-26-GinaDate13_487-cropped.png 

I get:

我得到:

convert: unable to open image `805X972+34+94': No such file or directory @ error/blob.c/OpenBlob/2702.

convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/504.

no decode delegate for this image format `' @ error/constitute.c/ReadImage/504

转换:无法打开图像`805X972+34+94':没有那个文件或目录@error/blob.c/OpenBlob/2702。

转换:此图像格式没有解码委托`'@ error/constitute.c/ReadImage/504。

此图像格式没有解码委托`'@ error/constitute.c/ReadImage/504

In the other posts on this issue, people get

在关于这个问题的其他帖子中,人们得到

convert no decode delegate for this image format `PNG'

不为此图像格式“PNG”转换解码委托

Or similar (except with their image type or filename and image type)

或类似(除了它们的图像类型或文件名和图像类型)

 

 

However, mine doesn't say anything about image file type...

但是,我的没有说明图像文件类型......

I have not tried uninstalling ImageMagick then installing it manually from sources because I'm not very confident at doing that... (this solution was shown: https://stackoverflow.com/a/34633084/5398660)

我还没有尝试卸载 ImageMagick,然后从源代码手动安装它,因为我对此不太有信心......(此解决方案已显示:https: //stackoverflow.com/a/34633084/5398660

Does anyone know what might be going on?

有谁知道可能会发生什么?

Also, can anyone help me interpret the @ error/constitute.c/ReadImage/504part? I'm looking at the code for constitute.cbut I'm not sure if I can get useful information from it to solve my problem (I only know a bit of C)

另外,谁能帮我解释@ error/constitute.c/ReadImage/504部分?我在看的代码constitute.c,但我不知道我是否可以从它那里得到解决我的问题有用的信息(我只知道一点的C)

Thank you!

谢谢!

回答by cfphpflex

brew remove imagemagick //to delete current version
brew install imagemagick --build-from-source

fixed it for me on mac

在 mac 上为我修好了

回答by SND

Throwing in my two cents as I too have struggled with this problem for the last few days. I had no problem running ImageMagick commands on my local machine, but got the error message as mentioned by OP when I ran the command from a Tomcat server running on Azure Cloud.

投入我的两分钱,因为过去几天我也一直在努力解决这个问题。我在本地机器上运行 ImageMagick 命令没有问题,但是当我从 Azure Cloud 上运行的 Tomcat 服务器运行命令时收到了 OP 提到的错误消息。

I could identify the cause by running the following command:

我可以通过运行以下命令来确定原因:

convert -list format

On my local machine, it would return quite a long list of all the supported formats, whereas on Kudu (Azure CLI tool) it would return an empty result. This indicates ImageMagick didn't find the path to its DLL files required for processing.

在我的本地机器上,它会返回很长的所有支持格式列表,而在 Kudu(Azure CLI 工具)上,它会返回一个空结果。这表明 ImageMagick 没有找到处理所需的 DLL 文件的路径。

In my case, the problem was simply caused by a lack of configuration on Azure:

就我而言,问题只是由于 Azure 上缺少配置造成的:

  • The absence of the ImageMagick root folder in the system environment variable %PATH%
  • The absence of an environment variable "MAGICK_HOME"(set to the root folder of your ImageMagick installation directory)
  • The absence of an environment variable "MAGICK_CODER_MODULE_PATH"(set to the folder mentioned above + /modules/coders)
  • 系统环境变量 %PATH% 中缺少 ImageMagick 根文件夹
  • 缺少环境变量“MAGICK_HOME”(设置为 ImageMagick 安装目录的根文件夹)
  • 缺少环境变量“MAGICK_CODER_MODULE_PATH”(设置为上面提到的文件夹+/modules/coders)

NOTE: for people who are also experiencing this problem on Azure, you can have a look at thisSO answer which explains how to add an environment variable using an XDT Transform.

注意:对于在 Azure 上也遇到此问题的人,您可以查看这个SO 答案,其中解释了如何使用 XDT 转换添加环境变量。

回答by Montag

Alright, with playing around I figured out the solution and I'm posting it here for other people who might run into this issue:

好吧,通过玩弄我找到了解决方案,我将其发布在这里供其他可能遇到此问题的人使用:

Apparently, this is not/no longer is/not for me the way to crop an image using ImageMagick convert. Even though this usage is shown hereit did not work for me using El Capitan (maybe it's the OS?).

显然,这对我来说不是/不再是/不再是使用 ImageMagick 转换裁剪图像的方式。尽管这里显示这种用法但它对我使用 El Capitan 不起作用(也许是操作系统?)。

Instead of using

而不是使用

convert img.png 805X972+34+94 img-crop.png

转换 img.png 805X972+34+94 img-crop.png

The correct command, which works is:

正确的命令是:

convert image.png -crop 805X972+34+94 image-crop.png

转换 image.png -crop 805X972+34+94 image-crop.png

 

 

That is, the command goes:

也就是说,命令是:

convert image.ext -crop heightXwidth+positionX+positionY* imagecropped.ext

转换 image.ext -crop heightX width+ positionX+positionY* imagecropped.ext

 

 

 

 

More can be found here. From the description on that ImageMagick page I was confused about the example where they have convert rose: -cropbut you can just use it the way I mentioned above and it works fine.

这里可以找到更多信息。从 ImageMagick 页面上的描述中,我对他们转换 rose: -crop的示例感到困惑,但您可以按照我上面提到的方式使用它,并且效果很好。

回答by lfender6445

I was receiving the same error for missing some single quotes.

由于缺少一些单引号,我收到了同样的错误。

When combining images with convert -drawwith quotes, the image supplied must be wrapped in quotes.

将图像与convert -draw与引号组合在一起时,提供的图像必须用引号括起来。

No decode delegate for this image format `' @ error/constitute.c/ReadImage/504

此图像格式没有解码委托`'@error/constitute.c/ReadImage/504

convert myBackground.png -font Arial -pointsize 20 \
  -draw "gravity west image Over 50,80,20,20 'myForeground.png'" \
  # -----------------------------------------^ added missing single quotes
  -flatten ./finalImage.jpg                  

When I added in the single quotes around myForegroundthe issue disappeared. What a lousy error!

当我在周围加上单引号时myForeground,问题就消失了。多么糟糕的错误!

回答by fmw42

An alternate Imagemagick command would be:

另一个 Imagemagick 命令是:

convert pic1-jpg.jpg[805x972+34+94] pic1-jpg-crop.jpg

or as stated earlier

或如前所述

convert pic1-jpg.jpg -crop 805x972+34+94 +repage pic1-jpg-crop.jpg

see Inline Image Crop at https://www.imagemagick.org/script/command-line-processing.php

请参阅https://www.imagemagick.org/script/command-line-processing.php 上的内联图像裁剪

Generally, I prefer the use of x (lower case) rather than X (uppercase) between the width and height, for easier reading. But either works.

通常,我更喜欢在宽度和高度之间使用 x(小写)而不是 X(大写),以便于阅读。但两者都有效。

回答by tiguchi

I also had to fight this problem today in a convert operation that applied a different color space profile.

我今天还必须在应用不同颜色空间配置文件的转换操作中解决这个问题。

It seems imagick's convert command is sensitive to the file extension of the profile's file name. In my case it was a temporary file without a suffix that triggered the same error message from the question title

似乎 imagick 的 convert 命令对配置文件文件名的文件扩展名很敏感。在我的情况下,它是一个没有后缀的临时文件,从问题标题中触发了相同的错误消息

convert infile.jpg -profile /tmp/profile-without-suffix outfile.jpg

Adding the correct suffix to the profile file name fixes the problem:

向配置文件名添加正确的后缀可解决此问题:

(assuming ICC format)

(假设ICC格式)

convert infile.jpg -profile /tmp/profile-without-suffix.icc outfile.jpg

回答by natebeaty

For me (on macos Mojave, using Imagick with CraftCMS) I had to reinstall Imagick with pecl uninstall imagickand pecl install imagick(and then restart Apache with sudo apachectl -k restart). I must have run brew upgradeand got a newer version of ImageMagick which caused Imagick to barf up a similar error of NoDecodeDelegateForThisImageFormat 'JPEG' @ error/constitute.c/ReadImage/556.

对我来说(在 macos Mojave 上,使用带有 CraftCMS 的 Imagick)我必须用pecl uninstall imagick和重新安装 Imagick pecl install imagick(然后用 重新启动 Apache sudo apachectl -k restart)。我一定已经运行brew upgrade并获得了更新版本的 ImageMagick,这导致 Imagick 出现了类似的NoDecodeDelegateForThisImageFormat 'JPEG' @ error/constitute.c/ReadImage/556.