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);
Related
Im usinf the following configuration on amazon AWS p3.2xlarge with 3D controller: NVIDIA Corporation GV100GL [Tesla V100 SXM2] (rev a1)
Centos 7
PHP7.2
Im trying to force Imagick to work with gpu memory instead of CPU
I have found the following article but im not sure how to implement it
https://www.imagemagick.org/script/opencl.php
can anyone assist ?
convert -version output
Version: ImageMagick 7.0.8-14 Q16 x86_64 2018-10-25 https://imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib
I installed ImageMagick using the instructions as below
export C_INCLUDE_PATH=/usr/local/cuda/include
export LD_LIBRARY_PATH=/usr/local/cuda/lib64
./configure --prefix=/usr --enable-shared --enable-openmp --enable-opencl --without-dps --without-djvu --without-fftw --without-fpx --without-gslib --without-gvc
make
sudo make install
While checking the imageMagick installation using
identify --version
It is showing as,
Version: ImageMagick 7.0.0-0 Q16 x86_64 2016-04-06
http://www.imagemagick.org Copyright: Copyright (C) 1999-2016
ImageMagick Studio LLC License:
http://www.imagemagick.org/script/license.php Features: Cipher DPC
HDRI OpenCL OpenMP Delegates (built-in): bzlib fontconfig freetype
jbig jng jpeg lcms lqr lzma openexr pangocairo png tiff wmf x xml zlib
When I check the device benchmark file as this :
$ cat ~/.cache/ImageMagick/ImagemagickOpenCLDeviceProfile
it shows
<version>ImageMagick Device Selection v0.9</version>
<device><type></type><name>Quadro M6000</name><driver>352.79</driver><max cu>24</max cu><max clock>1114</max clock><score>0.0960</score></device>
<device><type></type><score>1.1890</score></device>
But when i run the command
time convert /home/downloads/lan.jpg -convolve '-1, -1, -1, -1, 9, -1, -1, -1, -1' /home/downloads/convolve.png
I got the output as
real 0m1.077s user 0m3.072s sys 0m0.032s
In OpenMP i got the output as
real 0m0.946s user 0m3.096s sys 0m0.036s
When i worked with the convert binary file inside the package,
./convert /home/zlabs/lan.jpg -convolve '-1, -1, -1, -1, 9, -1, -1, -1, -1' /home/zlabs/convolve.png
i got
real 0m0.904s user 0m1.824s sys 0m0.024s
Actually the binary file is giving actual performance of opencl. How is it possible? What is happening actually? Is Opencl working or not?
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 would like to build a OpenCV from source using a libc++ STL library, instead of default GNU STL. LibC++ offers better C++11 and C++14 support. Is it possible to do that?
I've tested this with OpenCV 2.4.7 and Android NDK r10d.
First, you need to download OpenCV source. Unpack the source and replace the platforms/android/android.toolchain.cmake with version that suppports libc++.
Now, open modules/core/include/opencv2/core/operations.hpp and change line 69 from
(defined __GNUC__ && defined _STLPORT_MAJOR)
to
(defined __GNUC__ && (defined _STLPORT_MAJOR || defined _LIBCPP_VERSION))
Next, in folder platforms/scripts create a script cmake_android_arm_libcxx.sh with following contents:
#!/bin/sh
cd `dirname $0`/..
mkdir -p build_android_arm
cd build_android_arm
cmake -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 -DANDROID_STL=c++_static -DANDROID_NATIVE_API_LEVEL=android-8 -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_FAT_JAVA_LIB=OFF -DBUILD_JASPER=OFF -DBUILD_OPENEXR=OFF -DBUILD_PACKAGE=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_TIFF=OFF -DBUILD_WITH_DEBUG_INFO=OFF -DBUILD_opencv_androidcamera=OFF -DBUILD_opencv_contrib=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_legacy=OFF -DBUILD_opencv_ml=OFF -DBUILD_opencv_nonfree=OFF -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_stitching=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_videostab=OFF -DCMAKE_C_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all" -DCMAKE_CXX_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all -fvisibility-inlines-hidden" -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_EIGEN=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DWITH_TIFF=OFF -DWITH_TBB=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake $# ../..
If you want, you can tweak the parameters of the script (i.e. what is built and how).
Finally, export the path to your NDK build folder
export ANDROID_NDK=~/android-sdks/android-ndk-r10d/
and execute the script:
sh ./scripts/cmake_android_arm_libcxx.sh
Now enter to build_android_arm folder and build the OpenCV:
cd build_android_arm
make -j9
The libjpeg, libpng and other 3rd party libraries will appear in platforms/build_android_arm/3rdparty/lib and opencv libraries will appear in platforms/build_android_arm/lib folder.
This has been tested on Mac OS X 10.10, OpenCV 2.4.7 and Android NDK r10d.
Here is a script which I used to build OpenCV 3.0 with clang and libc++ for arm64 (for other ABI's just change toolchain name):
#!/bin/sh
export ANDROID_NDK=~/android-sdks/android-ndk
cmake -DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-clang3.5 -DANDROID_STL=c++_static -DANDROID_ABI="arm64-v8a" -DANDROID_NATIVE_API_LEVEL=android-8 -DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_DOCS=OFF -DBUILD_FAT_JAVA_LIB=OFF -DBUILD_JASPER=OFF -DBUILD_OPENEXR=OFF -DBUILD_PACKAGE=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_TIFF=ON -DBUILD_WITH_DEBUG_INFO=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_world=OFF -DCMAKE_C_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all" -DCMAKE_CXX_FLAGS_RELEASE="-Os -DNDEBUG -fvisibility=hidden -ffunction-sections -fstack-protector-all -fvisibility-inlines-hidden" -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_EIGEN=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DWITH_TIFF=ON -DWITH_TBB=ON -DWITH_CUDA=OFF -DWITH_CUFFT=OFF -DWITH_WEBP=OFF -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_TOOLCHAIN_FILE=$1/platforms/android/android.toolchain.cmake $1
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.