Hi,

I'm trying to resize the image in using GraphicsMagick and Wt.
(same as: $ gm convert -geometry "400x300>" in.png out.jpg)

---------- resize.cpp - this code work correctly (but not in Wt)
#include <Magick++.h>

int main(int argc, char **argv) {
  Magick::Image image;
  image.read(argv[1]);
  image.zoom(Magick::Geometry("400x300>"));
  image.write(argv[2]);
}

//compile: $ g++ -o resize resize.cpp -I/usr/include/GraphicsMagick
-lMagick++
//or compile: $ g++ -o resize resize.cpp `Magick++-config --cppflags
--cxxflags --ldflags --libs`
//run:     $ ./resize in.jpg out.jpg
----------


I tried using the Magick++ in Wt, it compiles but gives error when open
the site.

My Wt site:

----- CMakeLists.txt
include_directories(${Wt_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}
/usr/include/GraphicsMagick)
add_executable(test.wt test.cpp)
target_link_libraries(test.wt wt wthttp Magick++ ${Boost_LIBRARIES})
# `Magick++-config --cppflags --cxxflags --ldflags --libs`

----- Test.cpp
#include <Magick++.h>
...
Magick::Image image; //error: Segmentation fault
or
Magick::Image *image = new Magick::Image(); //error: Segmentation fault
or
Magick::Image image(); //ok
image.read("in.jpg"); //error: request for member ‘read’ in ‘image’,
which is of non-class type ‘Magick::Image()’

---------- resize1.cpp - this code work correctly too (but no in Wt)
#include <cstring>
#include <magick/api.h>

int main(int argc, char **argv) {
  Image *image;
  ImageInfo *image_info;
  ExceptionInfo exception;

  InitializeMagick(*argv);
  GetExceptionInfo(&exception);
  image_info = CloneImageInfo((ImageInfo *) NULL);

  (void) strcpy(image_info->filename, argv[1]);
  image = ReadImage(image_info, &exception);
  image = ResizeImage(image, 400, 300, LanczosFilter, 1.0, &exception);

  (void) strcpy(image->filename, argv[2]);
  WriteImage(image_info, image);

  DestroyImage(image);
  DestroyImageInfo(image_info);
  DestroyExceptionInfo(&exception);
  DestroyMagick();
}

//compile: $ g++ -o resize1 resize1.cpp -O `GraphicsMagick-config
--cppflags --ldflags --libs`
//run:     $ ./resize1 in.jpg out1.jpg

----------

Can anyone tell me where I am wrong?

Thanks.
John


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to