2003.12.19 07:14 "[Tiff] Reading and writing out TIFFTAG_CLIPPATH", by Jae Ho Lee

2003.12.26 02:02 "Re: [Tiff] Reading and writing out TIFFTAG_CLIPPATH", by Jae Ho Lee

Hi,

I want to let you that I solved this problem with a minor change to libtiff. My problem was that I was looking for ClipPath(343) tag which was not part of sample tiff I was working with. Sample tiff contained TIFFTAG_PHOTOSHOP(34377).

So, instead of trying to fetch clippath and write it out, I opted to fetch whole photoshop data and write it out. But I still could not write PHOTOSHOP tag data to newly created tiff image until I made below changes to TIFFWriteNormalTag() fuction in tif_dirwrite.c file.

Thanks for the feedbacks and help.

Regards,

Jae Ho

         // jaeho - 20031224
         // moved TIFF_BYTE case statement to TIFF_UNDEFINED because TIFFTAG_PHOTOSHOP tag couldn't be written.
         // when tag is TIFFTAG_PHOTOSHOP, 1) is executed but returned value for wc is zero
         // and no data is written for TIFFTAG_PHOTOSHOP tag.
         // 2) should be executed to write TIFFTAG_PHOTOSHOP data correctly but I opted to execute 3) instead.
//        case TIFF_BYTE:
         case TIFF_SBYTE:
             if (wc > 1) {
                   char* cp;
                       if (wc == (u_short) TIFF_VARIABLE
                           || fip->field_passcount) {
                          TIFFGetField(tif, fip->field_tag, &wc, &cp); // 1) when tag is TIFFTAG_PHOTOSHOP; wc = 0
                                dir->tdir_count = wc;
                   } else if (wc == (u_short) TIFF_VARIABLE2) {
                            TIFFGetField(tif, fip->field_tag, &wc2, &cp);  // 2) when tag is TIFFTAG_PHOTOSHOP
                              dir->tdir_count = wc2;
                  } else
                          TIFFGetField(tif, fip->field_tag, &cp);
                 if (!TIFFWriteByteArray(tif, dir, cp))
                          return (0);
                 } else {
                    if (fip->field_passcount) {
                             char* cp;
                               TIFFGetField(tif, fip->field_tag, &wc, &cp);
                            dir->tdir_count = wc;
                           if (!TIFFWriteByteArray(tif, dir, cp))
                                  return 0;
                       } else {
                                char cv;
                                TIFFGetField(tif, fip->field_tag, &cv);
                         if (!TIFFWriteByteArray(tif, dir, &cv))
                                 return (0);
                     }
                 }
                 break;

         // jaeho - 20031224
         // added TIFF_BYTE to support TIFFTAG_PHOTOSHOP
         case TIFF_BYTE:
  case TIFF_UNDEFINED:
            { char* cp;
               if (wc == (u_short) TIFF_VARIABLE) {
                  TIFFGetField(tif, fip->field_tag, &wc, &cp);
                    dir->tdir_count = wc;
             } else if (wc == (u_short) TIFF_VARIABLE2) {
                  TIFFGetField(tif, fip->field_tag, &wc2, &cp);  // 3) when tag is TIFFTAG_PHOTOSHOP
                      dir->tdir_count = wc2;
            } else
                        TIFFGetField(tif, fip->field_tag, &cp);
           if (!TIFFWriteByteArray(tif, dir, cp))
                        return (0);
             }
               break;

         case TIFF_NOTYPE:
                 break;
 }