I've googled my problem and found many pages, but none of them have exactly the same flavour and I can't get my problem to go away.
I have a program which uses Magick++ and works fine on my PC, but it fails on another computer where I'm trying to run the code. A minimal example is this:
#include <iostream>
#include <Magick++.h>
int main(){
Magick::Image im;
im.read( "/fullpathtoimage.jpg" );
std::cout<< im.columns() <<"\n";
return 0;
}
(where of course "/fullpathtoimage.jpg" is a valid image).
This raises an exception:
terminate called after throwing an instance of 'Magick::ErrorMissingDelegate'
what(): ImageMagick: NoDecodeDelegateForThisImageFormat `/fullpathtoimage.jpg' # constitute.c/ReadImage/503
Aborted
Other reports of this problem basically say that they don't have delegates for jpeg, and should install libjpeg etc, but they were getting the same errors when running 'convert'. However, when I do
./convert /fullpathtoimage.jpg temp.png
It runs perfectly. Doing
./identify -list configure
lists, amongst others
DELEGATES bzlib mpeg fontconfig freetype jng jpeg pango png ps x xml zlib
LIBS -lfreetype -ljpeg -lpng12 -lfontconfig -lXext -lXt -lSM -lICE -lX11 -lbz2 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lxml2 -lz -lm
and
./identify -list format | grep JPEG
gives
JNG* rw- JPEG Network Graphics
JPEG* rw- Joint Photographic Experts Group JFIF format (62)
PJPEG* rw- Joint Photographic Experts Group JFIF format (62)
So, all seems fine, all binaries work, just my code doesn't.
The version I installed is ImageMagick-6.8.7-8, I built it from sources as I don't have root access at the machine, and I installed it to a location within my home (using ./configure --prefix=/home/... ). I checked if maybe there's an issue with linking my program against wrong ImageMagick (as there is an older system one too), but ldd reveals all is fine i.e. the program is linked against the one I installed, as I wanted, and running ldd on convert shows it is linked against exactly the same libraries.
Related
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 using the armadillo library inside a package (LAMMPS package). I also used Armadillo to compile different codes, and it works fines, and I use the following compiling command:
g++ example2.cpp -o example2 -O3 -larmadillo -DARMA_DONT_USE_WRAPPER -lblas -llapack
Armadillo works fine for matrix storage and loading inside the package, however, when it comes to matrix-vector multiplication, it gives me the following error:
/usr/include/armadillo_bits/wrapper_blas.hpp:42: undefined reference to `dgemv_'
Any suggestion on how to go around it?
I tried to get FFTW and ImageMagick installed in remote server which I have NO root access. I reference this post and add following lines to my bashrc.
export PATH=$PATH:~/usr/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/usr/lib
export C_INCLUDE_PATH=$C_INCLUDE_PATH:~/usr/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:~/usr/include
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:~/usr/lib/pkgconfig
For FFTW installation, I ran command
./configure --prefix=/home/foo/usr --enable-openmp make make install
For libpng and ImageMagick, I ran command
./configure --prefix=/home/foo/usr make make install
To compile,
g++ main.cpp -o main 'Magick++-config --cppflags --cxxflags --ldflags --libs' 'pkg-config fftw3 --libs' -Wall
Compilation is succeed but following error appear when trying to run the program
terminate called after throwing an instance of 'Magick::ErrorMissingDelegate'
what(): Magick: no decode delegate for this image format PNG' # error/constitute.c/ReadImage/501
I got DELEGATES bzlib djvu fftw fontconfig freetype jbig jpeg jng jp2 lcms2 lqr lzma openexr pango png rsvg tiff x11 xml wmf zlib when i ran convert -list configure
Any one can help me with this?
Thank you!
I just fixed the problem! Even thought delegate has png in the list but I look back to the log when doing ./configure, the result of --with-png is no. Since I put libpng at /usr, the correct command is ./configure --prefix=/home/foo/usr LDFLAGS='-L/home/foo/usr/lib' CPPFLAGS='-I/home/foo/usr/include'
I complied ImageMagick-6.8.8 on Mac 10.9.2 with static libraries with support for Magick++.
Now I am trying to execute the following example from the Magick++ tutorial pdf on page 19 ( I have removed the comments from the following code
DrawableText::DrawableText(double x, double y, const string& text_to_write)
Image my_image(Geometry(320,220), Color("white"));
list<Drawable> text_draw_list;
text_draw_list.push_back(DrawableFont("-misc-fixed-medium-o-semicondensed—13-*-*-*-c-60-iso8859-1"));
text_draw_list.push_back(DrawableText(101, 50, "text to write on the canvas"));
text_draw_list.push_back(DrawableStrokeColor(Color("black")));
text_draw_list.push_back(DrawableFillColor(Color(0, 0, 0, MaxRGB)));
my_image.draw(text_draw_list);
I get the following error:
Magick: non-conforming drawing primitive definition `text' # error/draw.c/DrawImage/3193
Can you help me figure this out.
Also I cannot use annotate as I have not compiled X support in my libraries and I believe that using annotate requires X...
Here is the output from my configure command
Option Value
-------------------------------------------------------------------------------
Shared libraries --enable-shared=no no
Static libraries --enable-static=yes yes
Module support --with-modules=no no
GNU ld --with-gnu-ld=no no
Quantum depth --with-quantum-depth=16 16
High Dynamic Range Imagery
--enable-hdri=no no
Install documentation: yes
Delegate Configuration:
BZLIB --with-bzlib=yes yes
Autotrace --with-autotrace=no no
Dejavu fonts --with-dejavu-font-dir=default none
DJVU --with-djvu=yes no
DPS --with-dps=yes no
FFTW --with-fftw=yes no
FlashPIX --with-fpx=yes no
FontConfig --with-fontconfig=yes no
FreeType --with-freetype=yes no
GhostPCL None pcl6 (unknown)
GhostXPS None gxps (unknown)
Ghostscript None gs (unknown)
Ghostscript fonts --with-gs-font-dir=default none
Ghostscript lib --with-gslib=no no
Graphviz --with-gvc=no
JBIG --with-jbig=yes no (failed tests)
JPEG v1 --with-jpeg=yes yes
JPEG-2000 --with-jp2=
LCMS v1 --with-lcms=yes no
LCMS v2 --with-lcms2=yes no
LQR --with-lqr=yes no
LTDL --with-ltdl=yes no
LZMA --with-lzma=yes yes
Magick++ --with-magick-plus-plus=yes yes
MUPDF --with-mupdf=no no
OpenEXR --with-openexr=yes no
OpenJP2 --with-openjp2=yes no
PANGO --with-pango=yes no
PERL --with-perl=no no
PNG --with-png=yes yes
RSVG --with-rsvg=no no
TIFF --with-tiff=yes yes
WEBP --with-webp=yes no
Windows fonts --with-windows-font-dir= none
WMF --with-wmf=no no
X11 --with-x=no no
XML --with-xml=yes yes
ZLIB --with-zlib=yes yes
X11 Configuration:
X_CFLAGS =
X_PRE_LIBS =
X_LIBS =
X_EXTRA_LIBS =
Options used to compile and link:
PREFIX = /Users/awais/Downloads/Image_Magick/IMagick/im
EXEC-PREFIX = /Users/awais/Downloads/Image_Magick/IMagick/im
VERSION = 6.8.8
CC = clang
CFLAGS = -arch x86_64 -Wall -fexceptions -D_FORTIFY_SOURCE=0 -D_THREAD_SAFE -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CPPFLAGS = -I/Users/awais/Downloads/Image_Magick/IMagick/im/include/ImageMagick-6
PCFLAGS = -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
DEFS = -DHAVE_CONFIG_H
LDFLAGS = -L/Users/awais/Downloads/Image_Magick/IMagick/im/tmp/lib -arch x86_64 -L/Users/awais/Downloads/Image_Magick/IMagick/ImageMagick-6.8.8-10/magick -L/Users/awais/Downloads/Image_Magick/IMagick/ImageMagick-6.8.8-10/wand -L/opt/local/lib
MAGICK_LDFLAGS = -L/Users/awais/Downloads/Image_Magick/IMagick/im/lib -L/Users/awais/Downloads/Image_Magick/IMagick/im/tmp/lib -arch x86_64 -L/Users/awais/Downloads/Image_Magick/IMagick/ImageMagick-6.8.8-10/magick -L/Users/awais/Downloads/Image_Magick/IMagick/ImageMagick-6.8.8-10/wand -L/opt/local/lib
LIBS = -ltiff -ljpeg -lpng16 -L/opt/local/lib -llzma -lbz2 -lxml2 -lz -lm
CXX = clang
CXXFLAGS = -arch x86_64 -D_THREAD_SAFE -pthread
FEATURES = DPC
DELEGATES = bzlib mpeg jng jpeg lzma png tiff xml zlib
It'll save a lot of trouble by installing FontConfig, FreeType & Ghostscript. You probably already have X11 sitting in your systems /opt directory. If not, jump over to XQuartz and run the .dmg install. DejaVu & Window's fonts are nice to have, but not needed. After installing the font libraries, you'll need to re-configure ImageMagick (remember to make clean), and re-install.
For the Magick++ tutorial, the following line is a bit confusing, as it involves a few wildcards that you may not be familiar with.
DrawableFont("-misc-fixed-medium-o-semicondensed—13-*-*-*-c-60-iso8859-1")
From the API, it may be a better introduction to initialize a font directly.
Magick::DrawableFont::DrawableFont ( const std::string & family_,
Magick::StyleType style_,
const unsigned int weight_,
Magick::StretchType stretch_
)
Find a typeface you wish to use by running identify -list font
Font: Helvetica-Narrow
family: Helvetica Narrow
style: Normal
stretch: Condensed
weight: 400
glyphs: /usr/local/share/ghostscript/fonts/n019043l.pfb
Then it's just a matter of applying the correct parameters
DrawableFont font = DrawableFont("Helvetica Narrow",
NormalStyle,
400,
SemiCondensedStretch
);
text_draw_list.push_back(font);
text_draw_list.push_back(DrawableText(101, 50, "text to write on the canvas"));
text_draw_list.push_back(DrawableStrokeColor(Color("black")));
text_draw_list.push_back(DrawableFillColor(Color(0, 0, 0, MaxRGB)));
my_image.draw(text_draw_list);
consider the simplest gtk+ application:
#include <gtk/gtk.h>
int main( int argc, char *argv[])
{
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main();
return 0;
}
I compile it succesfully on Windows using this:
gcc -o hello.exe hello.c -mms-bitfields -IC:/gtk/include/gtk-2.0 -IC:/gtk/lib/gtk-2.0
/include -IC:/gtk/include/atk-1.0 -IC:/gtk/include/cairo -IC:/gtk/include/gdk-pixbuf-2.0 -IC:/gtk/include/pang
o-1.0 -IC:/gtk/include/glib-2.0 -IC:/gtk/lib/glib-2.0/include -IC:/gtk/include -IC:/gtk/include/freetype2 -IC:
/gtk/include/libpng14 -LC:/gtk/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lpangowin32-1.0 -lgdi
32 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0
-lintl
In order to run hello.exe as a standalone program I include whith it all the GLib, cairo, Pango, ATK, gdk-pixbuf, gettext-runtime, fontconfig, freetype, expat, libpng and zlib run-time packagages. The program runs very well, the problem is that all this run-time stuff takes about 40 MB of disk space.
¿Do this simple program need all the files in ./share/locale (25 MB)? ¿Is there any way to use the minimum run-time packages to run my application on Windows?
Thanks
./share/locale/* includes the translations, so you have to choose yourself. Do you want to have translations or do you want to save disk space?
Depending on how you ship your application (for example simply packed in a .rar or with an installer), you can install those translations conditionally.
The only required files are the libraries, like libgtk-x11-2.0.dll, libglib-2.0.dll, …