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

11

41

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

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)

 

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

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

In the other posts on this issue, people get

convert no decode delegate for this image format `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://mcmap.net/q/393216/-imagick-no-decode-delegate-for-this-image-format )

Does anyone know what might be going on?

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

Thank you!

Decalogue answered 2/6, 2016 at 14:3 Comment(4)
I think your missing the command operator before 805X972+34+94. The convert utility is treating the geometry argument as a file path.Lambaste
try convert /Users/Innovate/Desktop/crop/2015-04-26-GinaDate13_487.png -crop 805X972+34+94 /Users/Innovate/Desktop/crop/2015-04-26-GinaDate13_487-cropped.pngLambaste
haha thanks emcconville, I posted the solution just after posting this. I'm wondering if it differed from the example posted here: apple.stackexchange.com/a/128000/156787 because it's El CapitanDecalogue
You can do it by adding brackets [...] about your crop coordinates 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 or by putting -crop before the crop coordinates.Raymer
E
17
brew remove imagemagick //to delete current version
brew install imagemagick --build-from-source

fixed it for me on mac

Evite answered 25/2, 2018 at 16:17 Comment(2)
Part of my original response: Uninstalling and reinstalling ImageMagick via brew. Sorry for not explicitly putting the command, but I thought that would have been clear (clearly wasn't). I don't want others coming and getting frustrated when uninstalling and then rebuilding from source doesn't work.Decalogue
didnt work for meFukien
I
10

I had the same error on Ubuntu 20.04 and ImageMagick. Had to reinstalled ImageMagick with all add ons according to this instruction:

#These are the steps required in order to Install ImageMagick with JPG, PNG and TIFF delegates.

sudo apt-get update 

#Install Build-Essential in order to configure and make the final Install

sudo apt-get install build-essential 

#libjpg62-dev required in order to work with basic JPG files

sudo apt-get install -y libjpeg62-dev 

#libtiff-dev is required in order to work with TIFF file format

sudo apt-get install -y libtiff-dev 

#Download ImageMagick

wget https://www.imagemagick.org/download/ImageMagick.tar.gz 

#Untar Imagemagick

tar xvzf ImageMagick.tar.gz 

#Access the working directory

cd ImageMagick/[version_number] 

#Configure and make sure to disable the "shared" option

./configure --disable-shared

#Make

sudo make

#Install

sudo make install

#Final Check

sudo make check
Intertwine answered 9/2, 2021 at 9:19 Comment(3)
when I built ImageMagick-7.1.0-16 from source with default configuration, it installed to /usr/local/bin/magick which meant I needed the final command /usr/local/bin/magick mogrify -format jpg *.heicDamle
I would like to add a line in the front to check if pkg-config is installed. Without pkg-config, configure does not know where the installed libraries are such as libtiff.Narghile
Thanks. I found a link which indicates how to build from scratch to include JPG, PNG, TIFF, HEIC, and HEIF formats(which are all I need) and now I can convert whatever I like: gist.github.com/nickferrando/fb0a44d707c8c3efd92dedd0f79d2911Hardy
B
7

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.

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.

In my case, the problem was simply caused by a lack of configuration on 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)

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

Bemock answered 3/10, 2017 at 8:53 Comment(0)
D
4

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 here it did not work for me using El Capitan (maybe it's the OS?).

Instead of using

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

The correct command, which works is:

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

 

That is, the command goes:

convert image.ext -crop heightXwidth+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: -crop but you can just use it the way I mentioned above and it works fine.

Decalogue answered 2/6, 2016 at 14:17 Comment(3)
If you look at the example you linked to in your answer the OP missed out -crop in the code example. If you look at his animation you can see it contains -crop. rose is an image built into Imagemagick for testing and so it can be used as rose:Till
Thank you Bonzo, good attention to details. I updated the example I linked (with the animation) to fix the missing -crop. Thank you for explaining what "rose" is.Decalogue
Glad you sorted it out and were just unlucky to pick a bad piece of code. Once you get the hang of Imagemagick it can be quite straight forward. But it can also do very complicated commands.Till
F
3

Install ImageMagick with JPG, PNG and TIFF Delegates - Ubuntu (20.04)

Approach 1

Chances are, ImageMagick is already installed on your computer if you are using some flavor of Linux, and its likely not installed if you are using some form of Windows. In either case, you can type the following to find out:

  1. Clone the source repository:
git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick-7.1.0    
  1. Next configure and compile ImageMagick. Note the pkg-config script is required so that ImageMagick can find certain optional delegate libraries on your system. To configure, type:

    cd ImageMagick-7.1.0
    ./configure
    make
    
  2. If build fails, try gmake instead. For advanced users, we recommend a modules build:

    ./configure --with-modules
    
  3. If ImageMagick configured and compiled without complaint, you are ready to install it on your system. Administrator privileges are required to install. To install, type

    sudo make install
    
  4. You may need to configure the dynamic linker run-time bindings:

    sudo ldconfig /usr/local/lib
    
  5. Finally, verify the ImageMagick install worked properly, type

    /usr/local/bin/convert logo: logo.gif
    
  6. For a more comprehensive test, run the ImageMagick validation suite. Ghostscript and Freetype are prerequisites, otherwise expect the EPS, PS, PDF and text annotations tests to fail.

    make check
    

Approach 2

Follow the below link

Install ImageMagick with JPG, PNG and TIFF Delegates - Ubuntu (20.04)

Falsity answered 24/7, 2021 at 6:34 Comment(0)
F
2

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

Florence answered 29/4, 2019 at 20:50 Comment(0)
A
1

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

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

No decode delegate for this image format `' @ 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 myForeground the issue disappeared. What a lousy error!

Antimatter answered 5/2, 2017 at 22:15 Comment(0)
R
0

An alternate Imagemagick command would be:

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

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

Raymer answered 25/2, 2018 at 19:57 Comment(0)
B
0

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

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)

convert infile.jpg -profile /tmp/profile-without-suffix.icc outfile.jpg
Burkle answered 9/10, 2018 at 0:3 Comment(0)
I
0

I used a suitable docker image, for example:

docker run -v /path/to/picsdir/:/pics --rm dpokidov/imagemagick /pics/img.heic /pics/img.png

This helped me convert from HEIC to PNG.

Indistinctive answered 4/7, 2022 at 18:10 Comment(0)
S
0

This issue can also appear when you have a file in the directory that accidentally is named like an argument that you try using. In my case my command had -transparent transparent in it while a file named -transparent was in the same directory and thus ImageMagick got confused and tried to read such file.

Please ensure that your local directory does not contain any files that might collide with the arguments.

Solenne answered 5/1 at 12:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.