trouble with including ImageMagick in Xcode 4.1

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
phluxy
Posts: 2
Joined: 2011-12-27T17:48:06-07:00
Authentication code: 8675308

trouble with including ImageMagick in Xcode 4.1

Post by phluxy »

Hi everyone ! :D

I have some problem with the use of the libraries in Xcode.
I am not very good :? but I would like to try to use ImageMagick libraries with Xcode on Mac OSX lion (10.7). I have already installed ImageMagick (version : 6.7.4-0 Q16) thanks to MacPorts.
The compilation works but when I execute the program I have to kill it with some errors about bzip2 and I don't understand... why bzip2 ?

The code is very simple (only to understand how it works) :

Code: Select all

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <magick/api.h>
#include <magick/ImageMagick.h>

int main(int argc, const char * argv[]) 
{
    ExceptionInfo *exception;
    Image *image, *scaled_image;
    ImageInfo *image_info;
    
    /* Initialization of ImageMagick and useful structures */
    MagickCoreGenesis(*argv,MagickTrue);
    exception=AcquireExceptionInfo();
    image_info=CloneImageInfo((ImageInfo *)NULL);
    
    /* Reading an image */
    strcpy(image_info->filename,"image.bmp");
    image=ReadImage(image_info,exception);
    
    /* Reduces the size of an image */
    scaled_image=ResizeImage(image,320/4,240/4,LanczosFilter,1.0,exception);
    if (scaled_image != (Image*) NULL)
    {
        DestroyImage(image);
        image=scaled_image;
    }
    
    /* Saving the image in JPEG format and deallocation */
    strcpy(image->filename, "image.jpg");
    WriteImage(image_info,image);
    DestroyImage(image);
    
    /* Closing Imagemagick */
    MagickCoreTerminus();
    return(0);
    
}
the return of the program :

Code: Select all

GNU gdb 6.3.50-20050815 (Apple version gdb-1705) (Fri Jul  1 10:50:06 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys001
sharedlibrary apply-load-rules all
warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/blocksort.o" - no debug information available for "blocksort.c".

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/huffman.o" - no debug information available for "huffman.c".

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/crctable.o" - no debug information available for "crctable.c".

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/randtable.o" - no debug information available for "randtable.c".

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/compress.o" - no debug information available for "compress.c".

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/decompress.o" - no debug information available for "decompress.c".

warning: Could not find object file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/bzip2-1.0.6/bzlib.o" - no debug information available for "bzlib.c".

[Switching to process 59260 thread 0x0]
Assertion failed: (image != (Image *) NULL), function ResizeImage, file magick/resize.c, line 2563.
kill
Current language:  auto; currently minimal
quit
Program ended with exit code: 0
There is nothing in this folder "/opt/local/var/macports/build/"... but I have bzip2 installed on my system... :?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: trouble with including ImageMagick in Xcode 4.1

Post by magick »

You need to check for exceptions. It looks like your program could not read image.bmp, only the exception will tell you why. Try this code:

Code: Select all

if (image == (Image *) NULL)
  CatchException(exception);
phluxy
Posts: 2
Joined: 2011-12-27T17:48:06-07:00
Authentication code: 8675308

Re: trouble with including ImageMagick in Xcode 4.1

Post by phluxy »

Now it works !
I have to put the whole path of the file even if the file is on the root of the project...

Thanks for your help ! :D
Post Reply