How to write a tiled tiff?

Developers
Lu Wang
2012-12-27
2013-01-07
  • Lu Wang

    Lu Wang - 2012-12-27

    Hi, I am using the FreeImage .net library, and looking for a way to write a tiled tiff. I am setting the tiled width and length tags to the loaded image first, and then save it. But when open the tag viewer on this saved image, the tiled tags are not there, and the tiff image is not a tiled tiff.

    FITAG tileWidthTag = FreeImage.CreateTag();
    var widthKey = "TileWidth";
    FreeImage.SetTagKey(tileWidthTag, widthKey);
    FreeImage.SetTagCount(tileWidthTag, 1);
    FreeImage.SetTagType(tileWidthTag, FREE_IMAGE_MDTYPE.FIDT_SHORT | FREE_IMAGE_MDTYPE.FIDT_LONG);
    FreeImage.SetTagID(tileWidthTag, 322);
    short tilewidth = 64;
    FreeImage.SetTagValue(tileWidthTag, BitConverter.GetBytes(tilewidth));
    FreeImage.SetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, fImage, widthKey, tileWidthTag);

            FITAG tileHeightTag = FreeImage.CreateTag();
            var heightKey = "TileLength";
            FreeImage.SetTagKey(tileHeightTag, heightKey);
            FreeImage.SetTagCount(tileHeightTag, 1);
            FreeImage.SetTagType(tileHeightTag, FREE_IMAGE_MDTYPE.FIDT_SHORT | FREE_IMAGE_MDTYPE.FIDT_LONG);
            FreeImage.SetTagID(tileHeightTag, 323);
            short tileHeight = 64;
            FreeImage.SetTagValue(tileHeightTag, BitConverter.GetBytes(tileHeight));
            FreeImage.SetMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, fImage, heightKey, tileHeightTag);
    

    For the tiled width/length tag info: http://www.awaresystems.be/imaging/tiff/tifftags/extension.html

    And I also tried to load a tiled tiff, and tried to read all the tags from FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, the tiled tags are not found (or at least not exposed) by the library.

    FITAG tag;
    var metadata = FreeImage.FindFirstMetadata(FREE_IMAGE_MDMODEL.FIMD_EXIF_MAIN, fImage, out tag);
    unsafe
    {
    Console.WriteLine(FreeImage.GetTagKey(tag) + " - " + FreeImage.GetTagID(tag) + " - " + (int)FreeImage.GetTagValue(tag).ToPointer());
    }

            bool found = true;
            while (found)
            {
               found = FreeImage.FindNextMetadata(metadata, out tag);
               if(found)
               {
                   unsafe
                   {
                       Console.WriteLine(FreeImage.GetTagKey(tag) + " - " + FreeImage.GetTagID(tag) + " - " + *(int*)FreeImage.GetTagValue(tag).ToPointer());
                   }
    
               }
            }
    

    can anyone help? Thanks!

    Lu

     
    Last edit: Lu Wang 2012-12-27
  • Hervé Drolon

    Hervé Drolon - 2013-01-07

    Hi,

    FreeImage can load tiled TIFF (and convert them as a big image containing all tiles).
    However, it cannot write tiled images.

    Hervé

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks