Building portable ImageMagick ( I Guess static)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
audryste

Building portable ImageMagick ( I Guess static)

Post by audryste »

I need to Image magick ++ for converting BMP to JPG ( in memory)


So, first requirements that I need to fullfill is these...

1) There is no root priviliges
2) It must work by coping pasting to any other linux based system (on other system directory differs)
3) I need to support bmp to jpeg conversion
4) Settings environment variables is possible (like $MAGICK_HOME)


I done lot of googling and so else but still did not founded right way ( u could say that I am bit novice to linux)

So here what I got... this one worked for me until I tried copy pasteto other system:

http://studio.imagemagick.org/pipermail ... 16371.html // by that configuration everything worked fine there (also i unistalled previus version of magick image that have been before so it may be possilbe that jpeg conversion left from there)


so i made some code it worked...

but when i transferedeverything to other system... puted LD_LIBRAR_PATH and MAGICK_HOME variablesi got error:

terminate called after throwing an instance of 'Magick::ErrorMissingDelegate'
what(): Magick: no encode delegate for this image format `blog.jpg' @ error/constitute.c/WriteImage/1157


it is because it do not get jpeg delegates (coder/ modulers)... but they files are in the system (jpeg.so and all other kind stuff)...
so identity gives(but MOGRIFY WORKED FINE! in jpeg conversion):

Name Value
-------------------------------------------------------------------------------
CC gcc -std=gnu99 -std=gnu99
CFLAGS -fopenmp -g -O2 -Wall -pthread
CONFIGURE ./configure '--enable-shared' '--with-modules' '--with-quantum-depth=16' '--prefix=/home/audrius/libs/ImageMagick-6.6.3-0' '--exec-prefix=/home/audrius/libs/ImageMagick-6.6.3-0' '--disable-installed' '--enable-delegate-build'
COPYRIGHT Copyright (C) 1999-2010 ImageMagick Studio LLC
CPPFLAGS -I/home/audrius/libs/ImageMagick-6.6.3-0/include/ImageMagick
CXX g++
CXXFLAGS -g -O2 -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES fontconfig freetype jpeg jng png x11 xml zlib
DISTCHECK_CONFIG_FLAGS --disable-deprecated --disable-installed --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-perl=no
EXEC-PREFIX /home/audrius/libs/ImageMagick-6.6.3-0
HOST i686-pc-linux-gnu
LDFLAGS -L/home/audrius/libs/ImageMagick-6.6.3-0/lib -L/home/audrius/libs/ImageMagick-6.6.3-0/magick -L/home/audrius/libs/ImageMagick-6.6.3-0/wand
LIB_VERSION 0x663
LIB_VERSION_NUMBER 6,6,3,0
LIBS -lMagickCore -lfreetype -ljpeg -lfontconfig -lXext -lSM -lICE -lX11 -lz -lm -lgomp -lpthread -lltdl
NAME ImageMagick
PCFLAGS -fopenmp
PREFIX /home/audrius/libs/ImageMagick-6.6.3-0
QuantumDepth 16
RELEASE_DATE 2010-07-07
VERSION 6.6.3
WEBSITE http://www.imagemagick.org

we have to keep in mind that here variables like PREFIX are wrong, but if I set it correct in batch before launching program it should work just fine.... ( I used Eclipse to build program)

may be there is even way to make all those needed parts static and put to eclipse ... but i had trouble with that (all errors about references and other erorrs..)

i guess for command line (configuring) it should look like smth:

./configure --disable-shared --enable-delegate-build --with-quantum-depth=16 --prefix=`pwd` --exec-prefix=`pwd` --disable-installed

also by this line jpeg conversion will not be supported how to make this static???


any help will be highly appreciated!

also I will give feedback on this so many will can learn get something with it.


also code lines that use:
Blob blob( testPicture.str().c_str(), sizeof(HEADER)+2+size);
Image image( blob);
image.magick("JPEG");
image.write("blog.jpg");

everything compiles and worked on first linuxplatform
here workfine two if do just BMP writing with no compresion...



I guess thebest idea would be load jpeg delagate module from eclipse... But how ?


Really waiting for somehelp...
audryste

Re: Building portable ImageMagick ( I Guess static)

Post by audryste »

so no one didi it before and no one knows how to do it ?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Building portable ImageMagick ( I Guess static)

Post by anthony »

See Note from the "Architecture" Document on the IM Web site.

Or look at my own raw notes on this in....
http://www.cit.griffith.edu.au/~anthony ... gick.hints

Basically their are two forms of IM. 'Installed' (system) and 'non-installed' (personal)

One requires an environment variable MAGICK_HOME to find everything, the other does not.

Note I have multiple versions of IM installed on my system. A system installed and a special HDRI version I use for things like Fast Fourier Transforms. To call that latter one I have a special wrapper script, called "hdri"

Code: Select all

#!/bin/sh
#
#   hdri imagemagick_command....
#
# Run the HDRI version of imagemagick (or other personal installed IM)
#
###
#
#  Anthony Thyssen      1 July 2009
#

# Where is the HDRI version of IM stored (configure --prefix setting)
export MAGICK_HOME=/opt/im_hdri

# Yes these are still necessary - especially if MAGICK_HOME has moved
# from where IM was installed using configure --prefix
#
# The LD_LIBRARY_PATH is especially important to get the right library.
#
# However the PATH does not help IM find the "show:" delegate!
# That is the location of "display" is hardcoded in the show delegate!
# As such if the MAGICK_HOME directory is moved "show:" will fail
# unless I remove the path from the "delegate.xml" file and add the
# following environment variables.
#
export PATH="$MAGICK_HOME/bin:$PATH"
export LD_LIBRARY_PATH="$MAGICK_HOME/lib:$LD_LIBRARY_PATH"

# Execute the HDRI version of the command
exec "$@"
I use the above like...

Code: Select all

      hdri convert .....
or even

Code: Select all

     hdri  some_ImageMagick_script
It sets up environment, and a quick test such as

Code: Select all

   hdri convert -version
Version: ImageMagick 6.6.2-4 2010-06-08 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: HDRI
confirms I am using the special HDRI version of IM I built and installed into "/opt/im_hdri"
(set in the "configure" using --prefix)

However if my HDRI version of IM is not installed, it will automatically fall back to the normal IM 'convert' command.

NOTE I do not need to modify any other shell scripts, as the environment will be passed on into that script. Thus I can use a script with either versions of IM to compare results. However that will not work for PHP, unless the PHP script is modified to call the wrapper script itself.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
audryste

Re: Building portable ImageMagick ( I Guess static)

Post by audryste »

so as far as I understood i have to install it normaly with sudo with enverinment parametre

$EXPORT MAGICK_HOME="path to dir"

and to configure it with parameter ./configure --prefix=$MAGICKhome (another parameters)

after this i have to unistall it and i will have portable image magick binary with all delegates (coders)?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Building portable ImageMagick ( I Guess static)

Post by anthony »

You do not need sudo.

You can install with a configure --prefix setting to somewhere you can write.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
audryste

Re: Building portable ImageMagick ( I Guess static)

Post by audryste »

I connected several parts of "How to install Image magick" and this is what I got...

First you need to download delegates... I needed just jpeg... as without administrator (root) rights i fo this for delegate installation
(you can obtain it from http://www.imagemagick.org/download/delegates/ or http://www.ijg.org/)

cd /home/ubuntu/libs/ImageMagick-6.6.3-0/external/jpeg-8b
./configure --prefix='/home/ubuntu/libs/jpeg' --enable-shared --enable-static
make
make install


so image magick installation part; after downloading and extracting ImageMagick

cd '/home/ubuntu/libs/ImageMagick-6.6.3-0'

export LD_LIBRARY_PATH='/home/ubuntu/libs/jpeg/lib' // this one just in case
./configure --prefix='/home/ubuntu/libs/magick' --enable-shared --without-x CPPFLAGS=-I/home/ubuntu/libs/jpeg/include LDFLAGS=-L/home/ubuntu/libs/jpeg/lib
make
make install

// adding image magick to library path
LD_LIBRARY_PATH=/home/ubuntu/libs/magick/lib:$LD_LIBRARY_PATH



now you can feel free to program in c++(imagemagick++) do a lot of stuff and port it to another computer....

I strongly believe that this one "tutorial" should published somwhere on your site (image magick) for making ImageMagick with delegates without root rights... If you do this it would be nice if you would mention me :) :P :P
Post Reply