Page 1 of 1

Help Converting Halftone Offset to iOS

Posted: 2014-05-02T04:29:45-07:00
by ImageGandalf
Hi,

I'm looking for an ImageMagick expert to help me translate this halftone offset script that is listed in the docs to iOS:

Code: Select all

  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

I have managed to make a simple script that applies a poster effect to a UIImage:

Code: Select all

    MagickWandGenesis();

    MagickWand *wand = NewMagickWand();
    NSData *inData = UIImagePNGRepresentation(self.originalImage);
    MagickReadImageBlob(wand, [inData bytes], [inData length]);
   
    ImageInfo *image_info = AcquireImageInfo();
    ExceptionInfo *exception = AcquireExceptionInfo();
   
    MagickBooleanType status = MagickPosterizeImage(wand,6,MagickFalse);
    
    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();
So what I would need would be this line:

Code: Select all

MagickBooleanType status = MagickPosterizeImage(wand,6,MagickFalse);
replaced with the code necessary to apply the above halftone offset as efficiently as possible.

Please private message me if this is something you think you could do.

Thanks.