ImageMagick NegativeOrZeroImageSize .emf - imagemagick

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.

Related

ImageMagick generates corrupted PDF file

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

Paperclip, ImageMagick "UnrecognizedAlphaChannelType `remove'"

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/"

.CDR to .SVG Convert Using ImageMagick

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.

Can't install GhostScript in ImageMagick

Download latest version of ImageMagick. Unpacked it. Installing Ghostscript like this:
$ sudo apt-get install ghostscript
After that try to configure ImageMagick:
$ ./configure --with-gslib
$ make
$ make install
After that i try to conver PDF to jpg
$ sudo /usr/local/bin/convert in.pdf out.jpg
And i see this mistake
convert: no decode delegate for this image format `/tmp/magick-BzHdr4Kp-00000001' # error/constitute.c/ReadImage/544.
convert: Postscript delegate failed `in.PDF': Нет такого файла или каталога # error/pdf.c/ReadPDFImage/678.
convert: no images defined `out.jpg' # error/convert.c/ConvertImageCommand/3044.
What i'm doing wrong?
Try the following convert commands to see more precisely what's possibly going wrong:
convert a.pdf -debug coder a.jpg
convert a.pdf -debug all a.jpg
There will possibly be a lot of output going to stderr. Amongst the lines you may see where IM is looking for Ghostscript. Also, try
convert -list delegate
convert -list delegate | grep --color -E '(eps|pdf)'
to find with which exact commandlines ImageMagick tries to run Ghostscript (it may call gsx instead of gs, or it may look for it in /usr/local/bin/...). If you find any deviations from your real Ghostscript installation, you can possibly fix it by editing delegates.xml.
convert -list configure
will show you how ImageMagick is configured (and if, for example, gs was during compile-time in the list in DELEGATES variables). Here you also find where to look for delegates.xml:
convert -list configure | grep CONFIGURE_PATH
should list the directory where this (as well as some more) *.xml settings files are located which control how convert et al. behave...

Identity command is failing for pdf and txt files

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.

Resources