cloud goes social

Icon

computer, travel, movies, music, cuisine and more

Latest ImageMagick

UPDATE: iOS4.3 and Xcode4

Hi,
I’ve compiled the latest ImageMagick for iPhone with the usual png/tiff/jpeg compatibility. Everything is compiled so that it shouldn’t be rejected by Apple. Please let me know if that’s the case.

You can find the latest 6.6.1-5 version here:IM 6.6.1-5
Or if you dare the latest beta 6.6.1-6 here:IM 6.6.1-6

As usual you can find the latest updated working XCode project here:IM_Test project

I’m in talks with the developers of ImageMagick to try and have a “standard” build for iPhone so that everyone can just go there. I will keep you up to date with it.

Please report any issues you might have and especially if now the applications will be accepted by Apple!

Regards,

~C

Category: Code

Tagged: ,

71 Responses

  1. Richa Maheshwari says:

    Hi Cloud,

    Thanks for this library. As i am new to Imagemagick and wanted to include this in my iOS application. Can you suggest me something on the lines of how to convert or resize the image. As in my application i have to download the images from the server and then convert them to smaller sizes. How can we use Imagemagick for this purpose.

    I will be thankful for your response.

  2. Mogs says:

    Hi,

    What about iOS 5 and xCode 4.3.xx ? is there any updated version available of imageMagick ?

  3. Dimple says:

    Hi Cloud,
    Again I am here..
    Please help me to perform Multi-Point and Freeform Distorts in iPhone. Can you provide any sample???

    I am doing this but nothing seems to happen. I want to perform
    const double ctrlPts[4] = {300,11 ,120,50};
    const size_t q = 1;
    MagickDistortImage(magick_wand, ShepardsDistortion , q, ctrlPts, MagickTrue);

    Your tutorial on http://www.imagemagick.org/Usage/distorts/#shepards shows me these lines in shell script.
    I want to use it for Iphone. Can you please figure it out where I am wrong.
    “convert koala.gif -virtual-pixel Black \
    -distort Shepards ’30,11 20,11 48,29 58,29′ \
    koala_ear_pull.png”

  4. Dimple says:

    Hi Cloud,
    I am new to imageMAgick. I am using it in iphone.
    This is my code
    Image *img = GetImageFromMagickWand(magick_wand);
    const double ctrlPts[4] = {2,2,2,2};
    ExceptionInfo *d;
    Image *result = DistortImage(img, DePolarDistortion, 4, ctrlPts, MagickFalse, d);

    I am getting this error in console
    Assertion failed: (exception->signature == MagickSignature), function DistortImage, file magick/distort.c,

    • Cloud says:

      Hi,
      I don’t really know how to help you out on this one. Sorry! Try to see if it works on the PC before trying it on the iPhone!

      • Dimple says:

        Can u give a simple way…

        How to convert Image object to UIImage in iphone. Image object is not in imagewand… Please reply fast..

  5. Wes says:

    Hello,

    Thanks for your work with this library. I had a question about the library you compiled for the iPhone. DOes it work with jpeg2000 decoding? I have the need to decode jpeg2000 images on my iPad, will your library support that?

    Thanks!

    • Cloud says:

      Hi Wes, if you’d send me a sample I’ll test ti and let you know.
      ~C

      • George says:

        Sorry, I can’t find my post so I duplicate the question:

        MagickReadImage() can not load the jp2 file, the jp2 file generated from Preview application on the mac.

        The error message is: no decode delegate for this image format `/Users/majianglin/Library/Application Support/iPhone Simulator/4.3/Applications/8F0201E1-4BC1-485F-B125-262B712C2DD7/IM_Test.app/iphone.jp2′ @ error/constitute.c/ReadImage/532

        The code is below:

        - (void)posterizeImageWithCompression {
        // Here we use JPEG compression.
        NSLog(@”we’re using JPEG compression”);

        MagickWandGenesis();
        magick_wand = NewMagickWand();
        //NSData * dataObject = UIImagePNGRepresentation([UIImage imageNamed:@"iphone.png"]);//UIImageJPEGRepresentation([imageViewButton imageForState:UIControlStateNormal], 90);
        MagickBooleanType status;
        NSString *path = [[NSBundle mainBundle] pathForResource:@”iphone.jp2″ ofType:nil];
        status = MagickReadImage(magick_wand, [path cStringUsingEncoding:NSUTF8StringEncoding]);
        //status = MagickReadImageBlob(magick_wand, [dataObject bytes], [dataObject length]);
        if (status == MagickFalse) {
        ThrowWandException(magick_wand);
        }

        // posterize the image, this filter uses a configuration file, that means that everything in IM should be working great
        // status = MagickOrderedPosterizeImage(magick_wand, “h8x8o”);
        // if (status == MagickFalse) {
        // ThrowWandException(magick_wand);
        // }

        size_t my_size;
        unsigned char * my_image = MagickGetImageBlob(magick_wand, &my_size);
        NSData * data = [[NSData alloc] initWithBytes:my_image length:my_size];
        free(my_image);
        magick_wand = DestroyMagickWand(magick_wand);
        MagickWandTerminus();
        UIImage * image = [[UIImage alloc] initWithData:data];
        [data release];

        [imageViewButton setImage:image forState:UIControlStateNormal];
        [image release];
        }

      • Cloud says:

        I manually approve comments. Anyway, JPEG2000 is currently not supported by the iPhone port! Sorry!

        ~C

  6. Danny says:

    Hi Cloud. This is an awesome project. Thanks for all your great work … I’ll keep you posted on a pretty cool app I’m trying to develop.

    I was wondering if you’ve had a chance to compile your test project for a device running iOS 4.3? When I try it, it builds and runs great on the simulator but gives the following error when I try to compile and run on an iPhone 4:

    ld: in IM/libMagickCore.a, file is universal but does not contain a(n) armv7 slice for architecture armv7
    collect2: ld returned 1 exit status
    Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

    Any thoughts?

  7. Aaron says:

    Hi Cloud,

    I’m getting the pthreads error mentioned earlier above. I’ll have to register fully so I can test on my ipod and see how it goes, but I trust your word on the matter.

    Now, the reason I’m writing is because I’m seeing differences between the ImageMagick files used in your test XCode project, IM 6.6.1-5 and IM 6.6.1-6; that is – none of the three builds of ImageMagick are binary-equivalent. I get the pthreads error with semaphores when I use IM 6.6.1-5 and I don’t when I use the one from IM_Test. However, when I use the ImageMagick build from IM_Test, I don’t get any font rendering. I’m going to give a go with IM 6.6.1-6 now and see if my luck improves.

    –Aaron

  8. charles image says:

    Hi Cloud, what would be the memory footprint of imagemagick on iphone? thanks.

  9. Louisdd says:

    Hi Cloud,
    I’ve been trying to create a new project (iOs 4.2)
    I drag n’ dropped the whole “/IM/” directory in my projetct
    and include your library.
    Then I followed the steps on
    http://www.github.com/marforic/imagemagick_lib_iphone
    * Other Linker Flags: -lMagickCore -lMagickWand -lz -lbz2 -ljpeg -lpng
    * Header Search Paths: $(SRCROOT) – make it Recursive
    * Library Search Paths: $(SRCROOT) – make it Recursive
    On the lower left click on the small-wheel and select: Add User-Defined Setting
    * Key: OTHER_CFLAGS
    * Value: -Dmacintosh=1

    but I’m stell getting errors like
    error: magick/MagickCore.h: No such file or directory

    Is there something I missed ?
    thanks
    Louis

    • Cloud says:

      I’m not sure what “drag’n'drop” does. Make sure to import the IM directory. It obviously doesn’t find the MagickCore.h header. You import it like: “magick/MagickCore.h”? Also checkout the test project.

      -C

  10. Yasir says:

    Hi ,

    First of all .. Thank you very much for all these stuff . the only problem with imagemagic is its slowness .. its very slow when testing on device ..i just want to apply brightness and sharpness on the image with slider ..
    can you suggest me any solutions for this .. slider calls the function on value changed event . so the function is being called again again without delay also i have tested it with a simple button ..

    please advice

    Thanks
    Yasir

    • Cloud says:

      Hi Yasir,
      the only things that can be done is downloading always the latest compiled library from the IM ftp and using the uncompressed methods as shown in the test project. Also, in the slider, don’t hook the valueChanged method but one that signals that the user has stopped sliding it! Regards,
      -C

  11. Mikkel says:

    My application uses ImageMagick to generate animated gifs and has been approved since december. Check it out here!.

    Thanks for helping me out with ImageMagick.

  12. far says:

    hi, i downloaded the sample project but unable to compile it.I encountered following errors
    Undefined symbols:
    “___bzero”, referenced from:
    _TIFFReadRGBAImageOriented in libtiff.a(tif_getimage.o)
    _TIFFReadRGBAStrip in libtiff.a(tif_getimage.o)
    _TIFFReadRGBATile in libtiff.a(tif_getimage.o)
    “_posix_memalign”, referenced from:
    _AcquireAlignedMemory in libMagickCore.a(magick_libMagickCore_la-memory.o)
    ld: symbol(s) not found
    collect2: ld returned 1 exit status

  13. Ronald says:

    I am building a project where I’d like to have one instance of MagickWand in the foreground and another in the background. With my first tries, I get some conflicts like:

    Assertion failed: (wand != (MagickWand *) NULL), function MagickUnsharpMaskImageChannel, file wand/magick-image.c, line 12528.

    Is there anything that comes to mind that would circumvent these kinds of conflicts?
    Thanks for all your work on this, it’s great.

    • Cloud says:

      Hi Ronald,
      I didn’t understand fully what you mean by having one in background and one in foreground. Anyway, you can of course create two MagickWand instances:

      MagickWand * mwb = NewMagickWand();
      MagickWand * mwf = NewMagickWand();
      

      And later on combine them as you prefer (MagickCompositeImage());

      Regards,

      ~C

  14. Ronald says:

    This is great work! I have a question: I’m using this IM for iPhone in a project, on the simulator “MagickModulateImage” works quickly on a 1600×1200 pixel image, however on the device it is very slow — like several seconds when it’s less than a second on the simulator. Are there any special compiler options or other techniques I should be using to get IM to run fast on the iPhone? Thanks!

    • Cloud says:

      Hi Ronald,
      please remember that possibly you’re using a PC with >2GB of ram and with some powerful CPU, the iPhone has a 1GHz cpu (in the best case) and at maximum approximately 14MB of memory available to a running application (if it exceeds that it will terminate the application). Anyway, I did some tests a while ago to measure performance of IM on an iPhone 3G and you can find the results at: http://www.cloudgoessocial.net/2009/07/14/imagemagick-on-iphone-benchmarks/

      • Dan says:

        Do you think that ImageMagick could run a bit faster on the iPhone if you create Magick Persistent Cache file and then do one or several operations on that? I was exploring this and I think it would probably use ConvertImageCommand. Your thoughts?

      • Cloud says:

        I’m not sure and I don’t have really time to play with it. If you want to run benchmarks you can just take the test project and modify it. Then share the results here!

        Regards,

        ~C

  15. Dan says:

    This is very cool stuff. Thanks for helping out the community. Have you had a chance to see if the IM test case works for iOS 4.2?

    • Cloud says:

      I never ran test cases. Anyway, 4.2 should compile it without any problem when it will be released. The new script has been modified to use clang (LVM compiler), which will be default when working with Xcode4

      • Dan says:

        Hi Claudio. I’m glad to hear that it should be working for iOS 4.2. Right now, I’m working with the Beta of the SDK (3.2.5 pre-release) and the IM_test example project produces the following error on the console:

        Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
        pthread_mutexattr_destroy$UNIX2003 called from function AllocateSemaphoreInfo in image IM_Test. If you are encountering this problem running a simulator binary within gdb, make sure you ‘set start-with-shell off’ first.

        Have you run into this one before?
        Thanks,
        Dan

      • Cloud says:

        That message appears only while running on the simulator. I just noticed it last night (don’t know if it’s the new SDK that complains). When running on the phone it doesn’t appear and works all right.

        ~C

      • Dan says:

        That’s very interesting. Do you think this strange behavior warrants a bug report to Apple?

      • Cloud says:

        No, it’s because I think that the i386 version (the simulator one) uses pthreads or something that bugs it off. it’s really nothing to worry about.

        ~C

  16. Sam says:

    Ok, up and running and ran into a snag on ‘KernelInfo’. I’m trying to run a MagickColorMatrixImage which requires the matrix as a KernelInfo *, what is the format of the KernelInfo its expecting? I was hoping to just provide a 5×5 matrix of doubles but KernelInfo seems to want a lot of other information.

  17. Sam says:

    Is there any trick to including the libraries? I added the IM directory to my project under Frameworks and imported “MagickWand.h” and got 144 errors of ‘Magick/magick-config.h: No such file or directory’ for all the header files.

  18. ace says:

    Any recent attempts at compiling with 4.1? I get the good old error: There is no SDK with the name or path ‘iphoneosxxx’ even though I’ve updated the project build file of your XCode project to point to 4.1.

  19. Michael says:

    Thanks Claudio, great work. I wonder if you were able to take a look at graphics magick lately? Unfortunately one of the biggest drawbacks of imagemagick in my usecase is its slowness :-(

    • Cloud says:

      Hi Michael,
      unfortunately I’ve been really busy, and I fail at my fast attempt to compile GM when I tried first. If compiling GM is an easy task, starting from my latest custom script one should be able to do it so himself. Unfortunately when I tried I didn’t manage and I don’t have time right now to look into that.

      Regards,

      ~C

  20. If I have an Image object from GetImageFromMagickWand
    how to turn that into a UIImage?

    • Cloud says:
      size_t my_size;
      unsigned char * my_image = MagickGetImageBlob(magick_wand, &my_size);
      NSData * data = [[NSData alloc] initWithBytes:my_image length:my_size];
      free(my_image);
      magick_wand = DestroyMagickWand(magick_wand);
      MagickWandTerminus();
      UIImage * image = [[UIImage alloc] initWithData:data];
      [data release];
      

      as shown in the test project…

  21. Forrest says:

    When trying to integrate imagemagick with cocos2d-iphone, I got following errors:

    Libtool “build/Debug-iphonesimulator/libcocos2d libraries.a” normal i386
    cd /Users/apple/workspace/imagemagick/OilPainting2
    setenv MACOSX_DEPLOYMENT_TARGET 10.5
    setenv PATH “/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin”
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool -static -arch_only i386 -syslibroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk -L/Users/apple/workspace/imagemagick/OilPainting2/build/Debug-iphonesimulator -L. -LClasses -Lim -Llibs -LResources -Lim/im_configs -Lim/im_headers -Lim/im_libs -Llibs/cocos2d -Llibs/CocosDenshion -Llibs/cocoslive -Llibs/FontLabel -Llibs/TouchJSON -Lim/im_headers/jpeg -Lim/im_headers/magick -Lim/im_headers/png -Lim/im_headers/tiff -Lim/im_headers/wand -Llibs/cocos2d/Support -Llibs/TouchJSON/Extensions -Llibs/TouchJSON/JSON -filelist “/Users/apple/workspace/imagemagick/OilPainting2/build/OilPainting2.build/Debug-iphonesimulator/cocos2d libraries.build/Objects-normal/i386/cocos2d libraries.LinkFileList” -lMagickCore -lMagickWand -lz -lbz2 -ljpeg -lpng -framework AVFoundation -framework AudioToolbox -framework CoreGraphics -framework OpenAL -framework OpenGLES -framework QuartzCore /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib/libz.dylib -o “/Users/apple/workspace/imagemagick/OilPainting2/build/Debug-iphonesimulator/libcocos2d libraries.a”

    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: can’t locate file for: -lz
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: -lz is not an object file (not allowed in a library)
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: can’t locate file for: -lbz2
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: -lbz2 is not an object file (not allowed in a library)
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool: file: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib/libz.dylib is a dynamic library, not added to the static library
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool failed with exit code 1

    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1

    Anyone also tried this ?

    Thanks

    • Cloud says:

      I’m not 100% sure what you’re doing there. Anyway you’re linking to some dynamic libraries, which cannot be done when developing for the iPhone.

      Regards,

      ~C

  22. Giovanni says:

    Hi,
    Very cool work.
    I’not familiar with image magick.
    I need to adapt some script for commend line that uses “convert” command in order to use them into an iphone project.

    can some one help me ?
    Thanks

  23. nish says:

    Hi,

    This is the complete error. Any idea whats missing.

    sh: gs: command not found
    sh: gs: command not found
    project1: unable to read font `Verdana.ttf’ @ warning/annotate.c/RenderType/807.
    project1: delegate library support not built-in `/Users/nishant/Library/Application Support/iPhone Simulator/3.2/Applications/FA3736EF-5EB2-49B9-A13A-6E9D352E4C92/project1.app//sw/share/ghostscript/fonts/n019003l.pfb’ (Freetype) @ warning/annotate.c/RenderFreetype/1449.
    project1: Postscript delegate failed `/Users/nishant/Library/Application Support/iPhone Simulator/3.2/Applications/FA3736EF-5EB2-49B9-A13A-6E9D352E4C92/tmp/magick-w8fN6TLC’: No such file or directory @ error/ps.c/ReadPSImage/781.

  24. nish says:

    Hey,

    Have you got MagickAnnotateImage working on the iphone. I tried it but it does not work. I got these errors.

    project1: UnableToOpenConfigureFile `type.xml’ @ warning/configure.c/GetConfigureOptions/589.
    project1: UnableToReadFont `Verdana.ttf’ @ warning/annotate.c/RenderType/807.
    project1: DelegateLibrarySupportNotBuiltIn `Verdana.ttf’ (Freetype) @ warning/annotate.c/RenderFreetype/1449.

    • Cloud says:

      For type.xml make sure to include all the im_configs files (there is a file called type.xml) and to set the environmental variable as done in my test project:

      // set the path so that IM can find the configuration files (*.xml files)
      NSString * path = [[NSBundle mainBundle] resourcePath];
      setenv("MAGICK_CONFIGURE_PATH", [path UTF8String], 1);
      

      For the font I do not know, try with different fonts, if possible.

      Regards,

      ~C

  25. nish says:

    Can you send me your email address. I will send you a promo code.

  26. nish says:

    Approved Approved!!! Finally apple has approved my app. Thanks cloud…. Thanks a lot man….

  27. [...] 1.5.2010 – UPDATE: for the latest compiled libraries and test project please refer to: Latest ImageMagick [...]

Leave a Reply

Donate

If you appreciate my work, my applications, this blog in general or you simply feel like rewarding me for something please consider donate.
Any amount will motivate me in keeping up with the blog and the applications.


Thank you!

Donors

F. Olsen, W. Chang, W. Edmondson, C. Sharff, M. Brown, G. Helton, J. de Ruiter, K. Langner, K. Smith, T. OHalloran, B. Zabarauskas

Listening to ...