I'm trying to upload some photos into my Rails app. But I'm getting:
Paperclip::NotIdentifiedByImageMagickError in Admin::ImagesController#create
C:/Users/Dwayne/stream20110816-3680-1hm9dag-0.jpeg is not recognized by the 'identify' command.
I know this has been asked before. I thought I'd give my side of the story though, be a bit more verbose than the others, and in doing so help increase awareness of this terrible tragedy.
What platform are you on?
# uname
CYGWIN_NT-6.1-WOW64
Is ImageMagick installed?
# identify
Version: ImageMagick 6.4.0 01/19/10 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2008 ImageMagick Studio LLC
Where is it?
# which identify
/usr/bin/identify
Tell that to Paperclip:
# config/environments/development.rb
Paperclip.options[:command_path] = "/usr/bin"
See if all the files and folders work:
# identify C:/Users/Dwayne/stream20110817-1264-1xuum8v-0.jpg
stream20110817-1264-1xuum8v-0.jpg JPEG 249x262 249x262+0+0 PseudoClass 256c 8-bit 9.88281kb
# identify /cygdrive/c/Users/Dwayne/stream20110817-1264-1xuum8v-0.jpg
stream20110817-1264-1xuum8v-0.jpg JPEG 249x262 249x262+0+0 PseudoClass 256c 8-bit 9.88281kb
Try the same from within the Rails console:
# irb(main):005:0> system("identify C:/Users/Dwayne/stream20110817-1264-1xuum8v-0.jpg")
C:/Users/Dwayne/stream20110817-1264-1xuum8v-0.jpg JPEG 360x360 360x360+0+0 DirectClass 8-bit 32.3281kb
=> true
Still nothing?
Take it to Paperclip's GitHub.
Still nothing?
Hope that somebody here might know.
Courtesy of Travis Pessetto:
Uninstall ImageMagick for Cygwin, install ImageMagick for Windows and try again!
Related
I'm working on openSUSE Tumbleweed.
I have ImageMagick installed.
$ convert --version
Version: ImageMagick 7.1.0-52 Q16-HDRI x86_64 20549 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(4.5)
Delegates (built-in): bzlib djvu fontconfig freetype gslib jng jpeg lcms ltdl lzma png ps raw tiff x xml zlib
Compiler: gcc (12.2)
Notice that the PNG delegate is installed, at least according to --version.
Despite this, converting fails.
$ convert covalent_platform.svg covalent_platform.png
convert: no decode delegate for this image format `PNG' # error/constitute.c/ReadImage/776.
convert: no images defined `covalent_platform.png' # error/convert.c/ConvertImageCommand/3342.
Even identifying a non-PNG file fails, with the same PNG delegate problem.
$ identify covalent_platform.svg
identify: no decode delegate for this image format `PNG' # error/constitute.c/ReadImage/776.
Any ideas for what might be wrong here?
I reinstalled libpng-devel and reinstalled IM, but the problem remains.
I figured out the problem, thanks to #fmw42 pointing out that if magick -list format has no output then the installation is bad.
I had installed IM from https://imagemagick.org/script/download.php
These downloads are not compatible with openSUSE.
After uninstalling and reinstalling IM from https://software.opensuse.org/package/ImageMagick, everything works as expected.
I am installing imagemagick on Alpine, which picks up 7.0.10 version of imagemagick.
My primary use is to covert WMF to PNG.
But convert sample.wmf sample.png gives error
convert: no decode delegate for this image format `WMF' # error/constitute.c/ReadImage/572.
convert: no images defined `sample.png' # error/convert.c/ConvertImageCommand/3322.
As per https://www.imagemagick.org/script/formats.php, I also installed libwmf, which does not resolve the issue.
identify -list format | grep WMF does not return any result.
Updated Answer
You are in luck! GraphicsMagick can do it on alpine:latest:
apk add graphicsmagick
gm identify -version
GraphicsMagick 1.3.36 20201226 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2020 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP no
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG no
JPEG-2000 no
JPEG yes
Little CMS no
Loadable Modules yes
Solaris mtmalloc no
Google perftools tcmalloc no
OpenMP no
PNG yes
TIFF yes
TRIO no
Solaris umem no
WebP yes
WMF yes <--- HERE IT IS
X11 no
XML yes
ZLIB yes
Now do the conversion from WMF to PNG:
gm convert sample.wmf result.png
Original Answer
I don't think you'll be able to do that, with ImageMagick at least...
I tried installing libwmf on alpine:latest and then installing ImageMagick from source and it declined to use libwmf v0.2.12
So I checked what ImageMagick requires and it wants libwmf v0.2.8.2.
So I tried alpine:3.8 which can install libwmf v0.2.8.4 but ImageMagick still wouldn't accept that (xxx/ipa.h is missing).
So I looked back to alpine:3.3 and alpine:3.4 and they have no libwmf.
So I tried alpine:3.5 and that was the same libwmf version as alpine:3.8
TLDR; alpine:3.5's libwmf is too new for ImageMagick and alpine:3.4 doesn't have libwmf at all.
Note: I found the packages and versions of libwmf on this website.
I am running a project with these software versions:
Paperclip 4.2.0
Rails 4.0.4
RHEL 6
convert -version => ImageMagick 6.8.9-9
convert -list configure =>
DELEGATES bzlib mpeg freetype jng jpeg lcms png ps tiff x zlib
and am getting this error while processing images through Paperclip.
Command :: convert '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g.jpg' -auto-orient -resize "x85" -crop "85x85+21+0" +repage -alpha remove -strip '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g20141205-17371-1ym7alo.png'
convert: UnrecognizedAlphaChannelType `remove' # convert.c/ConvertImageCommand/636.
Cocaine::ExitStatusError: Command 'convert '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g.jpg' -auto-orient -resize "x85" -crop "85x85+21+0" +repage -alpha remove -strip '/tmp/a583e7c175d537c0442da246e5184fe120141205-17371-tvp3g20141205-17371-1ym7alo.png'' returned 1. Expected 0
Here is the command output:
from /home/proj/.rvm/gems/ruby-2.1.1/gems/cocaine-0.5.4/lib/cocaine/command_line.rb:96:in `run'
This error is caught on the Thumbnail processor in the make method.
The most confusing part of this is that I set a debugger when this error is caught, copied the src tmpfile to a permanent location outside my project and ran the exact same convert command as above and it runs successfully with exit status 0.
My next step in debugging would probably to bundle open cocaine, but I think there is something higher level going wrong... Hoping someone has run into this before?
I don't get the same problem on OSX.
You may have multiple installations of ImageMagick installed. You can check at the command line like so:
$ which -a convert
If you do have multiple installations, and Paperclip is referencing the "wrong" one, Paperclip allows you to specify the path to seek. As from the Paperclip README:
In development mode, you might add this line to config/environments/development.rb:
Paperclip.options[:command_path] = "/usr/local/bin/"
When running compare
compare -metric MSE some-image-1.jpg some-image-2.jpg /dev/null
1) When images are identical (OK)
0 (0)
This is what I would expect to see.
2) When images differ (OK)
Error: Command failed: 13.1266 (0.000200299)
I can get the data that I want, but I'm not sure why it's presented as an error.
3) When image is a JPEG with a Photoshop colour profile (ISSUE)
Error: Command failed: lcms: Error #12288; Corrupted memory profile
This is the real issue, and only happens on JPEG images with a Photoshop colour profile - can anyone point me to why this would happen?
Environment
OS X 10.9.4
GhostScript 9.07 at /opt/Ghostscript
compare at /opt/ImageMagick/bin/compare
Version: ImageMagick 6.8.8-6 Q16 x86_64 2014-02-17 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC
Delegates: bzlib fftw jng jpeg lcms lzma png tiff webp xml zlib
Thank you for your time.
For some reason tests fail for pdf and txt files, however using the app through the browser I am able to upload both of these formats.
Any ideas for how to fix this?
Error that is thrown:
Image /tmp/stream20110105-27382-hc9w7l-0.pdf is not recognized by the 'identify' command..
Output of identify command calls:
# png file works
[chris#chris-archlinux test]$ identify fixtures/files/brown-1920x1080.png fixtures/files/brown-1920x1080.png PNG 1920x1080 1920x1080+0+0 8-bit DirectClass 257KB 0.000u 0:00.000
# jpg works
[chris#chris-archlinux test]$ identify fixtures/files/avatar.jpg fixtures/files/avatar.jpg JPEG 478x478 478x478+0+0 8-bit DirectClass 72KB 0.000u 0:00.000
# txt fails
[chris#chris-archlinux test]$ identify fixtures/files/file_2.txt identify: unable to read font `/usr/share/fonts/Type1/n019003l.pfb' # error/annotate.c/RenderFreetype/1059. identify: no decode delegate for this image format `/tmp/magick-XXKkKcoe' # error/constitute.c/ReadImage/532. identify: unable to get type metrics `fixtures/files/file_2.txt' # error/txt.c/ReadTEXTImage/256.
# pdf fails
[chris#chris-archlinux test]$ identify fixtures/files/file.pdf identify: no decode delegate for this image format `fixtures/files/file.pdf' # error/constitute.c/ReadImage/532.
Are you using Paperclip for attachments? If so, read on. Otherwise ignore...
I remember having a similar error when trying to use Paperclip. It was because my executable path wasn't setup right. Assuming you have all the imagemagick binaries installed, try adding the following to an initialize or environment file:
My OS X env uses:
Paperclip.options[:command_path] = "/usr/local/bin"
Linux env uses:
Paperclip.options[:command_path] = "/usr/bin"
try:
pacman -S ghostscript
As root. That ought to fix your pdf problem, at least.