Graphicsmagick C ++ API

I want to use C ++ API for graphicsmagick

I need to convert image data directly from OpenCV and use graphicsmagick to save the file as tiff with group 4 compression

Command line

 gm convert input -type bilevel -monochrome -compress group4 output.tif 

Can someone provide some code (see command line above) to just convert output from OpenCV to tiff with group 4 compression

I am new to C ++ :)

graphicsmagick testing

I am trying to make graphicsmagick work. Found a very simple code in the docs

I can not find Magick++.h

locate /Magick++.h nothing

but graphic magic is set

 # gm -version GraphicsMagick 1.3.20 2014-08-16 Q8 http://www.GraphicsMagick.org/ 

the code

 /* * Compile * g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs` */ #include <Magick++.h> using namespace std; using namespace Magick; int main(int argc, char **argv){ InitializeMagick(*argv); Image image( "100x100", "white" ); image.pixelColor( 49, 49, "red" ); image.write( "red_pixel.png" ); return 0; } 

compilation

 # g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs` -bash: GraphicsMagick++-config: command not found gm_test.cpp:6:22: fatal error: Magick++.h: No such file or directory #include <Magick++.h> ^ compilation terminated. 
+7
c ++ imagemagick graphicsmagick
source share
3 answers

Updated Answer

Try to find a file called GraphicsMagick-config in the directory where you installed GraphicsMagick as follows:

 find /usr -name "GraphicsMagick-config" 

When you find this, you can ask him to tell you that the compiler flags and linker flags are included:

 /usr/some/path/GraphicsMagick-config --cflags --libs 

Then you can compile with:

 gcc $(/usr/some/path/GraphicsMagick-config --cflags --libs) somefile.c -o somefile 

Original answer

Look at the directory where you installed GraphicsMagick for the file ending in .pc , which is the pkg-config file, for example

 find /usr/local -iname "graphic*.pc" 

Then pass this file to pkg-config to get the CFLAGS and LIBS that you should use to compile. So if your graphicsmagick.pc is in /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc , use:

 pkg-config --cflags --libs /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc 

which will give you the following:

 /usr/local/Cellar/graphicsmagick/1.3.23/lib/pkgconfig/GraphicsMagick.pc -I/usr/local/Cellar/graphicsmagick/1.3.23/include/GraphicsMagick -L/usr/local/Cellar/graphicsmagick/1.3.23/lib -lGraphicsMagick 

Then you compile with:

 gcc $(pkg-config --cflags --libs somefile.c -o somefile 
+5
source share

I don't know if this is useful, the last day I got the same error: no magick ++. h when I compile ImageMagick (and not graphicsmagick). so I follow the steps on the official website to reinstall ImageMagick, and finally I succeeded .web:

1 http://www.imagemagick.org/script/install-source.php
2 http://www.imagemagick.org/script/magick++.php

Download the latest source code (ImageMagick6.9) in centOS-6.5 and then. / configure, make, make install. I hope this will be helpful.

0
source share

On Ubuntu, the GraphicsMagick++-config program that you use to get compilation flags is the right part of the same package that Magick ++ includes. h. Trying to run it will tell you where to find it:

 $ g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs` The program 'GraphicsMagick++-config' is currently not installed. You can install it by typing: sudo apt-get install libgraphicsmagick++1-dev gm_test.cpp:6:22: fatal error: Magick++.h: No such file or directory 

compilation completed.

So do what he says:

 $ sudo apt-get install libgraphicsmagick++1-dev 

Retry compilation and you will get another error, because GraphicsMagick++-config refers to a remote and unnecessary library:

 $ g++ gm_test.cpp -o gm_test `GraphicsMagick++-config --cppflags --cxxflags --ldflags --libs` /usr/bin/ld: cannot find -lwebp collect2: error: ld returned 1 exit status 

You can manually specify libraries, and compilation and link work:

 $ g++ gm_test.cpp -o gm_test -I/usr/include/GraphicsMagick -Wall -g -fno-strict-aliasing -O2 -pthread -lGraphicsMagick++ -lGraphicsMagick -ljbig $ ./gm_test 

Or you can install the required library:

 $ sudo apt-get install libwebp-dev 
0
source share

All Articles