marforic / imagemagick_lib_iphone

Scripts and instructions to compile ImageMagick as a static library to use in any iOS project
314 stars 71 forks source link

Possible to do Command in iOS ImageMagick? #11

Closed kissfro closed 10 years ago

kissfro commented 10 years ago

I have:

 MagickWandGenesis();
MagickWand *wand = NewMagickWand();
NSData *data = UIImagePNGRepresentation(self.originalImage);
MagickReadImageBlob(wand, [data bytes], [data length]);

int arg_count = 3;
char *args[] = { "-ordered", "-dither", "h4x4a", NULL};

ImageInfo *image_info = AcquireImageInfo();
ExceptionInfo *exception = AcquireExceptionInfo();

MagickBooleanType status = ConvertImageCommand(image_info, arg_count, args, NULL, exception);

if (exception->severity != UndefinedException)
{
    status = MagickTrue;
    CatchException(exception);
}

if (status == MagickFalse)
{
    NSLog(@"FAIL");
}

size_t my_size;
unsigned char * my_image = MagickGetImageBlob(wand, &my_size);
NSData *outData = [[NSData alloc] initWithBytes:my_image length:my_size];
free(my_image);

self.imageView.image = [[UIImage alloc] initWithData:outData];

image_info=DestroyImageInfo(image_info);
exception=DestroyExceptionInfo(exception);
DestroyMagickWand(wand);
MagickWandTerminus();

And it doesn't work. Have tried everything, was wondering if there is an example somewhere.

AcidicSkittles commented 10 years ago

What exactly are you trying to accomplish?

kissfro commented 10 years ago

@AcidicSkittles In this code I'm just trying to execute a basic command and apply a simple halftone pattern on a UIImage. Ultimately, I'm trying to build up to be able to implement this command:

convert parrots_med.png -set option:distort:viewport '%wx%h+0+0' \ -colorspace CMYK -separate null: \ ( -size 2x2 xc: ( +clone -negate ) \ +append ( +clone -negate ) -append ) \ -virtual-pixel tile -filter gaussian \ ( +clone -distort SRT 2,60 ) +swap \ ( +clone -distort SRT 2,30 ) +swap \ ( +clone -distort SRT 2,45 ) +swap \ ( +clone -distort SRT 2,0 -blur 0x0.7 ) +swap +delete \ -compose Overlay -layers composite \ -set colorspace CMYK -combine -colorspace RGB \ offset_parrots.png

Do you know if this is even possible with ImageMagick iOS?

AcidicSkittles commented 10 years ago

I don't know if it's possible to convert a command line to something that image magick on ios can interpret. you might be best off digging through the list of api functions here http://www.imagemagick.org/api/magick-image.php and finding what you're trying to do

marforic commented 10 years ago

Hi, you should convert the command line into the correct API calls.

Best

~C

On Monday, May 5, 2014, kissfro notifications@github.com wrote:

@AcidicSkittles https://github.com/AcidicSkittles In this code I'm just trying to execute a basic command and apply a simple halftone pattern on a UIImage. Ultimately, I'm trying to build up to be able to implement this command:

convert parrots_med.png -set option:distort:viewport '%wx%h+0+0' \ -colorspace CMYK -separate null: \ ( -size 2x2 xc: ( +clone -negate ) \ +append ( +clone -negate ) -append ) \ -virtual-pixel tile -filter gaussian \ ( +clone -distort SRT 2,60 ) +swap \ ( +clone -distort SRT 2,30 ) +swap \ ( +clone -distort SRT 2,45 ) +swap \ ( +clone -distort SRT 2,0 -blur 0x0.7 ) +swap +delete \ -compose Overlay -layers composite \ -set colorspace CMYK -combine -colorspace RGB \ offset_parrots.png

Do you know if this is even possible with ImageMagick iOS?

— Reply to this email directly or view it on GitHubhttps://github.com/marforic/imagemagick_lib_iphone/issues/11#issuecomment-42207428 .

System Security Group ETH Zurich CNB F 100.5 Universitätsstrasse 6 8092 Zurich SWITZERLAND

Phone: +41 44 633 76 99 E-Mail: maclaudi@inf.ethz.ch Web: http://www.syssec.ethz.ch/people/maclaudi

kissfro commented 10 years ago

Thanks for your feedback guys.