ICC profile and dpx settings

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
jgbas67

ICC profile and dpx settings

Post by jgbas67 »

Hello,
I´m developing a little C program using C wand. I´m use to C, but I´m new in IM. I´ve been reeading IM documentation and lots of messages here, but didn´t get anywhere. My program has to read an image, aply an ICC profile and save it in dpx log 10 format. Now is working, but not completely ok. My questions are:

1- How I aply the ICC profile? I´ve been reading, but did´t got anything clear. Should I use MagickSetImageProfile or MagickProfileImage? what are this parameters const void *profile and const size_t length? My profile is in an .icc file.

2- I´m setting some dpx attributes using things like MagickSetOption(magick_wand, "dpx:television.gamma","1.6"), but others (included in http://www.imagemagick.org/script/motio ... properties) doesn´t work. like dpx:television.white_level or dpx:file.version.

I´m using ImageMagick 6.5.1 Q16 in windows, i put the important part of my code (very similar to IM examples). If anyone could help me i would be very grateful!

Code: Select all

// Initializate and open the image
               magick_wand=NewMagickWand();
               MagickReadImage(magick_wand, argv[1]);
               MagickResetIterator(magick_wand);
               
               while (MagickNextImage(magick_wand) != MagickFalse){
                 //This operations works ok
                 MagickNegateImage(magick_wand, MagickFalse);
                 MagickAdaptiveResizeImage(magick_wand, atoi(Ancho), atoi(Alto));
                 MagickFlipImage(magick_wand);
                 MagickSetOption(magick_wand, "dpx:television.gamma","1.6");
                 MagickSetOption(magick_wand, "dpx:film.frame_id","scn_12023");


                 // This doesn´t work
                MagickSetOption(magick_wand, "dpx:television.white_level","95");
                MagickSetOption(magick_wand, "dpx:television.black_level","685");
                MagickSetOption(magick_wand, "dpx:file.version","v0.1");

               //MagickProfileImage(magick_wand, "ICC", "img/AdobeRGB1998.icc", profile);
               //MagickSetImageProfile(magick_wand, "ICC", "img/AppleRGB.icc.icc", profile);
               }

               status = MagickWriteImages(magick_wand,argv[2],MagickTrue);
               if (status == MagickFalse)
                 printf("error al escribir la imagen");

               magick_wand=DestroyMagickWand(magick_wand);
thanks in advance!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: ICC profile and dpx settings

Post by magick »

1- How I aply the ICC profile? I´ve been reading, but did´t got anything clear. Should I use MagickSetImageProfile or MagickProfileImage? what are this parameters const void *profile and const size_t length? My profile is in an .icc file.
Use MagickSetImageProfile() to simply add a profile to an image. Use MagickProfileImage() to actually transform a colorspace (e.g. transform RGB to CMYK).
2- I´m setting some dpx attributes using things like MagickSetOption(magick_wand, "dpx:television.gamma","1.6"), but others (included in http://www.imagemagick.org/script/motio ... properties) doesn´t work. like dpx:television.white_level or dpx:file.version.

dpx:television.white_level requires floating point value but it should set without complaint. You can get the dpx:file.version property but cannot set it. ImageMagick fixes the file version at 2.0.
jgbas67

Re: ICC profile and dpx settings

Post by jgbas67 »

first of all thanks for the reply, but i´ve some doubts...
Use MagickSetImageProfile() to simply add a profile to an image. Use MagickProfileImage() to actually transform a colorspace (e.g. transform RGB to CMYK).
ok, i should use MagickProfileImage(), but I don´t understand the parameters of this function:

wand: my wand, everything ok.
name: the name of the profile; ok.
const void *profile: I don´t understand this. where should we pointing this? Should I open the .icc file before?
const size_t length: I don´t know what is this, neither what is it for.

I´m trying this:

Code: Select all

    size_t *profile;
    MagickProfileImage(magick_wand, "ICC", "img/AdobeRGB1998.icc", profile);
and I get this error:

Code: Select all

lcms: Error #12288; Read from memory error. Got 512 bytes, block should be of 12
8 bytes
lcms: Error #12288; Corrupted memory profile
I think it is because a bad use of the parameters, is it?

dpx:television.white_level requires floating point value but it should set without complaint.
Without succes´, Ive tried:

Code: Select all

    MagickSetOption(magick_wand, "dpx:television.white_level","95,0");
    MagickSetOption(magick_wand, "dpx:television.black_level","685.0"); 

    MagickSetOption(magick_wand, "dpx:source.device.serialnumber","1234");
    MagickSetOption(magick_wand, "dpx:file.creation.datetime","29/04/2009");
    MagickSetOption(magick_wand, "dpx:mp.film.manufacturer","kodak");
Can anyone see anything wrong?
thanks a lot and excuse me as i don´t know very much about digital images.
jgbas67

Re: ICC profile and dpx settings

Post by jgbas67 »

I´m still trying to set the dpx attributes, but always without succes. Now i´m trying with the command line.

I´ve tried:

Code: Select all

convert en3.jpg -set reference-white 685  img2.dpx
convert en3.jpg -set reference-black 95  img2.dpx
convert en3.jpg -set gamma 1.7 img2.dpx
and always the same result:

Code: Select all

identify -format "%[dpx:*]" img2.dpx
dpx:file.creator=ImageMagick 6.5.1-6 2009-04-22 Q16 OpenMP http://www.imagemagic
k.org
dpx:file.ditto.key=1
dpx:file.timestamp=2009-05-07T11:17:44+02:
dpx:file.version=V2.0
dpx:film.frame_position=0
dpx:film.held_count=0
dpx:film.sequence_extent=0
dpx:image.orientation=0
dpx:orientation.aspect_ratio=0x0
dpx:orientation.border=0x0+0+0
dpx:orientation.x_offset=0
dpx:orientation.x_size=0
dpx:orientation.y_offset=0
dpx:orientation.y_size=0
dpx:television.time.code=00:00:00:00
dpx:television.user.bits=00:00:00:00
Is the command ok? Could it have some mistake? I´m running IM 6.5.1 Q16 in windows vista, I don´t know if this could be helpful.

thanks again!
jgbas67

Re: ICC profile and dpx settings

Post by jgbas67 »

After a long time trying, i resolved the problem with the ICC profile. I put my working code looking to help anyone with this problem. The dpx settings issue is still a problem for me.

I don´t know if this is a good way, but it works. hope my code will we useful to someone!

Code: Select all

   size_t profile_size=0;
   FILE *ICCfile;
   int cantLeidos;
   unsigned char buffer[2048];
   // the first parmeter is the ICC file path
   if ((ICCfile =fopen("webcoated.ICC","rb"))==NULL){
      printf("Error while opening the ICC file");
   }else{
        while ((cantLeidos = fread(buffer,1,2048, ICCfile))){
              profile_size +=cantLeidos;
        }
   }

   unsigned char ICC[profile_size];
   rewind(ICCfile);
   fread(ICC, 1, profile_size, ICCfile);
   //now we have the ICC file content in memory, in ICC  
   fclose(ICCfile);

    MagickProfileImage(magick_wand,"ICC",ICC, profile_size);
draxil
Posts: 7
Joined: 2011-11-17T05:18:40-07:00
Authentication code: 8675308

Re: ICC profile and dpx settings

Post by draxil »

Thanks for this it was a real help.
Post Reply