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.
Related
When I try to convert an image to PDF using ImageMagick by executing the command
mogrify -format pdf ImageMagick.png
the resulting PDF is corrupted. When I try to open it using MuPDF it fails:
error: cannot recognize version marker
warning: trying to repair broken xref
warning: repairing PDF document
error: name too long
warning: skipping ahead to next token
error: invalid key in dict
error: invalid key in dict
error: name too long
warning: skipping ahead to next token
error: no objects found
mupdf: error: cannot open document
The output of ImageMagick using the -verbose-flag is:
ImageMagick.png PNG 600x621 600x621+0+0 8-bit sRGB 123261B 0.020u 0:00.009
ImageMagick.png=>ImageMagick.pdf PNG 600x621 600x621+0+0 8-bit sRGB 122974B 0.070u 0:00.060
The problem with the PDF file seems to be, that the first bytes of the file aren't %PDF-.
This is my input-file
And this is the resulting PDF
My system:
Arch Linux
ImageMagick 7.0.8-8 Q16 x86_64 2018-08-01 (installed by executing pacman -S imagemagick)
The problem was, that ghostscript wasn't installed. ImageMagick doesn't seem to throw an error when ghostscript isn't installed.
To install ghostscript use
pacman -S ghostscript
Your command is just rewriting a PNG over itself. I don't know how the ImageMagick.pdf file was generated, but it really is just a PNG image with a PDF filename. Try one of the following...
convert ImageMagick.png ImageMagick.pdf
... or ...
mogrify -format PDF -path ./ ImageMagick.png
I'm using Wine on Ubuntu 16.04 and ImageMagick-7.0.3-5-portable-Q16-x64 to convert .emf files to .png.
The .emf file is 44.8 MB and has dimensions 3264x2448
I'm using the following from inside the portable folder:
wine convert.exe ../test.emf ../test.png
which errors with:
fixme:ver:GetCurrentPackageId (0x23b850 (nil)): stub
convert.exe: NegativeOrZeroImageSize `../test.emf' # error/image.c/SetImageExtent/2453.
convert.exe: NoImagesDefined `../test.png' # error/convert.c/ConvertImageCommand/3253.
So perhaps it's failing to get the size of the emf?
wine identify.exe -ping -format '%w %h' ../test.emf
Which errors with
identify.exe: NegativeOrZeroImageSize `../test.emf' # error/image.c/SetImageExtent/2453.
Note, I ran indentify.exe on a test ../test.jpg image and it worked correctly so I know the paths are correct.
I'm, trying to flatten a whole directory of .png images to have a white background.
The following command works on a single file:
magick convert -flatten "c:\Users\LibrarySurface2\OneDrive\Pictures\2016-08-09 archive of coworking space feedback\20151214 115702.png" "c:\Users\LibrarySurface2\OneDrive\Pictures\2016-08-09 archive of coworking space feedback\20151214 115702-white.png"
...however when I try to run it against the whole directory (1300 or so images) using the following command:
magick convert -flatten *.png *-w.png
It fails out with a bunch of these, and then stops running because of "too many exceptions" any thoughts on what could be causing this?
convert: Expected 3949 bytes; found 2684 bytes .\20160426 114948.png' # warning/png.c/MagickPNGWarningHandler/1683.
convert: Read Exception.\20160426 114948.png' # error/png.c/MagickPNGErrorHandler/1650.
convert: corrupt image .\20160426 114948.png' # error/png.c/ReadPNGImage/4029.
convert: Expected 4585 bytes; found 929 bytes.\20160429 145040.png' # warning/png.c/MagickPNGWarningHandler/1683.
convert: Read Exception .\20160429 145040.png' # error/png.c/MagickPNGErrorHandler/1650.
convert: corrupt image.\20160429 145040.png' # error/png.c/ReadPNGImage/4029.
convert: Expected 8192 bytes; found 8037 bytes .\20160504 165938.png' # warning/png.c/MagickPNGWarningHandler/1683.
convert: Read Exception.\20160504 165938.png' # error/png.c/MagickPNGErrorHandler/1650.
convert: corrupt image `.\20160504 165938.png' # error/png.c/ReadPNGImage/4029.
Make a backup first, then use mogrify instead:
mogrify -flatten *.png
Explanation: In general, use the convert command when you want one output file and mogrify when you want multiple output files.
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/"
I am on CentOS 6.4 and trying to convert .CDR to .SVG Convert Using ImageMagick using SSH command.
my 1.cdr file is in /var/www/vhosts/website.com/httpdocs/test/1.cdr
once converted to SVG it should be created in the same folder
Tried the following command:
convert /var/www/vhosts/website.com/httpdocs/test/1.cdr image.svg
The Error I am getting is:
sh: mplayer: command not found convert: Delegate failed "mplayer"
"%i" -really-quiet -ao null -vo png:z=3' #
delegate.c/InvokeDelegate/1032. convert: missing an image filename
image.svg' # convert.c/ConvertImageCommand/2800.
Not sure what does that mean ?
In order to convert CDR files you need to install uniconvertor for CDR delegate.
List of all delegates:
convert -list delegate
By default it outputs:
cdr => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
Install uniconvertor. For example, on Ubuntu it’s:
sudo apt-get install python-uniconvertor
Then run:
convert image.cdr -flatten -thumbnail '512x512' image.png
Or, with zoom cropping:
convert image.cdr -flatten -thumbnail '512x512^' -gravity center -crop 512x512+0+0 +repage image.png
And you’re done.
I convert to PNG here but you may use your own output format.
python-uniconvertor is part of inkscape.
It does not exist by itself.
Ubuntu/Mint recently removed all the old Python stuff, for Corel Draw I have to fire up the WinXP VM & Corel and export something Linux understands, usually PNG, a favourite
CDR & WMF files are pretty much dead to Linux, ImageMagick can still handle WMF though.