Converting CMYK jpg to RGB png

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

We don't have MagickWand for PHP installed but we did try the following program with the C MagickWand library which MagickWand for PHP relies on and got expected results. We're using ImageMagick 6.2.8-5 and the image comparison return exact results. The command line:
  • -> convert cmyk.tif -profile USWebCoatedSWOP.icc -profile sRGB.icm im_rgb.miff
    -> wand
    -> compare -metric rms im_rgb.miff im_rgb.png test.miff
    0 dB
    1024,701,MIFF
The wand.c code:

Code: Select all

#include <stdio.h>
#include <wand/magick-wand.h>

int main()
{
  ExceptionInfo
    *exception;

  MagickWand
    *wand;

  unsigned char
    *profile;

  size_t
    length;

  MagickWandGenesis();
  wand=NewMagickWand();
  MagickReadImage(wand,"cmyk.tif");
  profile=MagickRemoveImageProfile(wand,"ICC",&length);
  if (profile == (unsigned char *) NULL)
    (void) printf("%s: does not have a ICC color profile\n","cmyk.tif");
  exception=AcquireExceptionInfo();
  profile=FileToBlob("USWebCoatedSWOP.icc",~0UL,&length,exception);
  MagickSetImageProfile(wand,"ICC",profile,length);
  profile=FileToBlob("sRGB.icm",~0UL,&length,exception);
  exception=DestroyExceptionInfo(exception);
  MagickProfileImage(wand,"ICC",profile,length);
  MagickWriteImage(wand,"im_rgb.png");
  MagickWandTerminus();
  return(0);
}
Post Reply