imagemagick wmf support on Alpine Linux - imagemagick

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.

Related

Why does ImageMagick fail with "no decode delegate for this image format `PNG'" even when the png delegate is installed?

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.

ImageMagick convert OOMing inside Singularity container

When I run a specific ImageMagick convert command (to produce an animated GIF) inside a Singularity container it is consistently giving an memory error:
convert-im6.q16: cache resources exhausted `foo.gif' # error/cache.c/OpenPixelCache/4083.
convert-im6.q16: memory allocation failed `foo.gif' # error/quantize.c/AssignImageColors/496.
How can I debug this?
I'm not getting any memory issues outside of Singularity which gives me the impression that either Singularity is artificially limiting my available memory or ImageMagick is configured poorly inside of Singularity. I am not seeing memory issues for any of my other applications running inside Singularity which makes me think it's an ImageMagick issue.
Here are some details about my system:
$ singularity --version
singularity version 3.7.1-1.el8
Inside the container:
Singularity> convert --version
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://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 webp wmf x xml zlib
and
Singularity> convert -list resource
Resource limits:
Width: 16KP
Height: 16KP
List length: 18.446744EP
Area: 128MP
Memory: 256MiB
Map: 512MiB
Disk: 1GiB
File: 768
Thread: 256
Throttle: 0
Time: unlimited
The Memory: 256MiB stands out as especially low. I should have at least 2GiB. How does ImageMagick configure these limits and how can I change them?
The problem turned out to be with ImageMagick's system-wide policy.xml that was installed in my container. Updating that file with more generous "memory" and "disk" values fixed this problem.
You can find the location of your system's policy.xml file using the command convert -list policy (Hat tip to Kurt Pfeifle's answer which clued me in on this). For me it was at /etc/ImageMagick-6/policy.xml. You can edit that file
(if you have root access). In the end I decided just to delete the file since I don't want my system from restricting my use at all inside the container.
You can set limits via the command line, say convert -limit memory 2GiB ... or environment variables (See Kurt Pfeifle's answer for details). However, this method does not allow expanding larger than system-wide limits set in policy.xml because this policy file is meant to be a way for system administrators to forcibly limit users. Therefore, the only way to remedy this is to update/remove the system-wide policy.

convert wmf to jpg with graphicsmagick, unable to read font

I try to convert a wmf file into a jpg. gm says it is "Unable to read font (n021004l.pfb) [No such file or directory]." My command is like that:
gm convert 456.wmf 456.jpg
What could be wrong? I am using the latest gm version 1.3.29 and have ghostscript installed. OS: Windows 7
Here's the small file that I am trying to convert: https://mycloud.m-box.at/index.php/s/lBMeCG0cjK45sI1
And here's the version log (wmf is enabled):
GraphicsMagick 1.3.29 2018-04-29 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2018 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 yes
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG yes
JPEG-2000 yes
JPEG yes
Little CMS yes
Loadable Modules yes
OpenMP yes (200203)
PNG yes
TIFF yes
TRIO no
UMEM no
WebP yes
WMF yes
X11 no
XML yes
ZLIB yes
Windows Build Parameters:
MSVC Version: 1500
This looks a bit odd. I would suggest you enable debugging messages and see if you can trace what is going wrong yourself.
So, use:
gm convert -debug all 456.wmf 456.jpg > debug.txt 2>&1
and then look at the last few lines in debug.txt.
Sorry I can't help further!

Check for ImageMagick current version based on that uninstall or Install

We are going for penetration testing and for that reason I need to upgrade ImageMagick on our server to 7.0.2-2 because previous version 6.7.x.x (which we currently run) has some high vulnerabilities and to get rid of them we plan to update this.
I want to mange it through ansible and to do a separate installation I have a script but this script doesn't check if there is any previously installed version. It would be great if some can help me in writing a script which first checks for any previous version if there is one uninstalls it and then do new installation of upgraded version.
Many thanks in advance!
You can obtain the version by parsing it out of the first line of output from
identify --version
e.g., on a nearly up-to-date host:
$ identify --version
Version: ImageMagick 7.0.1-1 Q16 x86_64 2016-06-24
http://www.imagemagick.org Copyright: Copyright (C) 1999-2016
ImageMagick Studio LLC License:
http://www.imagemagick.org/script/license.php Features: Cipher DPC
HDRI Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig
jng jpeg lcms lqr lzma openexr png tiff wmf x xml zlib
or on a not-so-up-to-date host:
$ identify --version
Version: ImageMagick 6.6.9-6 2011-04-28 Q16
http://www.imagemagick.org Copyright: Copyright (C) 1999-2011
ImageMagick Studio LLC Features:
Use "sed" or your favorite editor to extract the version string:
identify --version|sed "-e s/Version: ImageMagick //" -e "s/ .*//"|head -1

convert: Wrong JPEG library version: library is 80, caller expects 90 `image.jpg'

I am using Ubuntu 13.04.
I am installing imagemagick. and It is installed properly via source.I find all required delegates.
convert -list configure | grep DELEGATES
I get :
DELEGATES bzlib djvu fontconfig freetype jbig jng jp2 jpeg lcms lqr lzma openexr png ps tiff x xml zlib
Now, Same code was working in OS Ubuntu 12.10 before.
Please guide how to solve issue
convert: Wrong JPEG library version: library is 80, caller expects 90image.jpg' `

Resources