no decode delegate for this image format `PNG' - wand

I'm writing a django/python application and I need to convert PDF files uploaded by the user to JPEGs (files are scans)
I'm trying to use wand, with an ImageMagick backend (on OSX) and
I keep getting the following error:
MissingDelegateError at /user_docs/upload/certificate/
no decode delegate for this image format `PNG' # error/constitute.c/ReadImage/501
My current test code is as simple as:
with wandImage(filename='/Users/username/Pictures/telechargement.pdf') as img:
img.format = 'jpeg'
img.save(filename='/Users/username/Pictures/bzzz.jpeg')
Some information:
The file exists (I verify with os.path.exists)
I can convert the file from PDF to JPG on the command line using convert
I tried to set DYLD_LIBRARY_PATH to include the ImageMagick lib directory
identify -list configure | grep DELEGATES returns
DELEGATES bzlib fftw fontconfig freetype gs jpeg jng lcms2 lzma mpeg png tiff x11 xml zlib
Anyone has an idea?
Thanks

OK, Found it! As always the key is RTFM:
http://docs.wand-py.org/en/0.4.0/guide/install.html#install-imagemagick-on-mac
I was missing the:
$ export MAGICK_HOME=/opt/local

Related

Why is magick giving an error while converting base64 files?

I have a bunch of base64 encoded images which I want to convert to their corresponding image files using magick (ImageMagick version 7). I can paste the base64 directly into various online converters which works. But command-line magick is failing.
Example of a file is attached in "x.txt". Pasting it into an online converter like https://onlinejpgtools.com/convert-base64-to-jpg readily yields an image. But this command line fails:
magick inline:`cat x.txt` x.png
This says "magick: corrupt image". If I remove the "inline" part, I get "magick: unable to open image". Here is a link to download the sample file x.txt:
In Imagemagick, try (no cat). That works for me.
magick inline:x.txt x.png
Or pipe from cat to magick as
cat tmp.txt | magick inline:- y.png

Why does this SVG to ICO conversion with ImageMagick batch script I wrote produce broken images?

Okay I've been doing a bunch of searching on this topic and I can't seem to find a good answer on this website, so please read this entire thing before marking it as a duplicate or whatever.
I'm writing some personal zsh utilities to make it easy for me to batch process icons into various different formats.
Here's the version output info for the imagemagick convert utility
┌─ ~/LinuxSVGsets/Dex_KDE/actions
└─➤ convert -version
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Here is my current script
function svg2icoBatch () {
for fname in $1/**/*.svg
do
#take off the svg
pathAndName=${fname%.svg}
#take off the path from the file name
iconname=${pathAndName##*/}
#take off the file name from the path
iconpath=$pathAndName:h
#create new folder for converted icons to be placed in
mkdir -p ${iconpath}/ico-converted/
convert $fname -background none -density 256 -define icon:auto-resize=16,32,48,64,256 ${iconpath}/ico-converted/${iconname}.ico
echo "\033[1;33m converted ${iconname}.svg to ico\n \033[0m"
done
}
the resulting ico looks like garbage:
When I try opening them up on an online ico viewer to make sure this wasn't just something weird with the image previewer utility in Ubuntu, I see a super blurry version of the icon that doesn't include it's additional sizes. I have no clue what I'm doing wrong here.
Any clues?

ImageMagick no decode delegate for this image format `PDF' Windows

Trying to play with ImageMagick to read scanned PDF texts, but at the point to convert the PDF to image, I've got this error, where it shows "no decode delegate for this image format `PDF' # error/constitute.c/ReadImage/504". Been search for this solution for hours to no avail, need some help here.
OS: Windows 7 x64
ImageMagick Version: ImageMagick-6.9.8-10-Q16-x86-dll.exe
convert -list format
shows below output
Format Module Mode Description
-------------------------------------------
* native blob support
r read support
w write support
+ support for multiple images
Looks like your delegates are not properly configured,
Once Ghostscript is installed make sure the binary folder C:\Program Files/gs/gs3.0.9/bin is added to your path.
Once Done, there should be a file names delegates.mgk in you graphics magick home directory. Open that file in a text editor.
<delegate decode="pdf" encode="eps" mode="bi" command='"#PSDelegate#" -q -dBATCH -dSAFER -dMaxBitmap=50000000 -dNOPAUSE -sDEVICE=#GSEPSDevice# "-sOutputFile=%o" -- "%i" -c quit' />
In the whole file, find and replace #PSDelegate# with gswin64c and it should get the job done.

Image Magick is generating black images while converting pdf to jpg

Image Magick version in use is 6.8.8.1.
Via command line on windows I am just trying to convert a *.pdf file into .jpg file using the following command
convert -density 100 -colorspace RGB "input.pdf" "output.jpg"
But the resulting output.jpg file is with a black image (there is no content). Any one out there could please guide on this ?
When you open this PDF-file by using a text-editor and it's header contains something like this:
%PDF-1.5
%¦éÏÄ
4 0 obj
<</Length 5 0 R/Filter /FlateDecode>>stream
....
....
then you have to decode this flat-encoded stream first before you can convert it to an image.
To solve this problem:
You can use the GUI-Tool pdftk free, set your environment-path to the bin-folder within the pdftk-folder and execute:
pdftk ENCODED_FILENAME.pdf output DECODED_FILENAME.pdf uncompress
in the shell to deflate/unzip this file.
Create a new file that is not encoded or zipped.
Hope this helps.
Set alpha flag to off in convert command.

ImageMagick Warning (TIF Conversion)

When I convert a Multi-Image TIF File to Individual TIF Files using ImageMagick I'm getting a Warning stating "Invalid TIFF Directory; tags are not sorted in ascending order'.
convert.exe: Invalid TIFF directory; tags are not sorted in ascending order.
'TIFFReadDirectoryCheckorder' # warning/tiff.c/TIFFWarnings/847
Hoping for Any advice I can get on this error. I am trying to take a Multi-Image TIF File and Turn it into Individual Files, however I need them to be in the order in which they were listed in the Original TIF File for this to work.
If you still have the issue check the limitation disk:
convert -list resource
Example for debian 9 /etc/ImageMagick-6/policy.xml.
I hope that could be helpful.

Resources