AWARE SYSTEMS
TIFF and LibTiff Mail List Archive

Thread

2004.09.01 20:39 "[Tiff] Stacked tiffs with colourmaps", by David Scriven
2004.09.02 01:27 "Re: [Tiff] Stacked tiffs with colourmaps", by Joris
2004.09.02 01:44 "Re: [Tiff] Stacked tiffs with colourmaps", by Chris Cox
2004.09.02 16:22 "Re: [Tiff] Stacked tiffs with colourmaps", by Ross A. Finlayson
2004.09.02 17:08 "Re: [Tiff] Stacked tiffs with colourmaps", by Bob Friesenhahn
2004.09.02 18:12 "Re: [Tiff] 16bit compressed colormaps", by Joris
2004.09.21 16:16 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline
2004.09.20 21:30 "[Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline
2004.09.21 16:01 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Joris
2004.09.27 19:14 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline
2004.09.27 19:34 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Joris
2004.09.24 13:02 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Joris
2004.09.24 12:36 "[Tiff] Possible (tiny) bug in LZW code", by Joris
2004.09.24 13:30 "Re: [Tiff] Possible (tiny) bug in LZW code", by Joris

2004.09.27 19:14 "Re: [Tiff] Alias Sketchbook Multi-Layer Tiff Files -- Specification", by Ian Ameline

At Joris' suggestion, I have registered a custom tag with Adobe. It's 50784. (it's type is ASCII) The revised Alias Layers In Tiff spec follows. Is this now sufficient to get placed along with the other extended tags on http://www.awaresystems.be/imaging/tiff/tifftags/private.html, with the docs below attached?

         Alias Multi-Layer TIFF File Format Specification
                        Ian Ameline
                       Alias Systems

                      (Sep 27, 2004)

Summary

Alias Sketchbook Pro is a sketching and imaging application that is capable of manipulating and storing multi-layer images, much as Adobe Photoshop does. We decided against using the Photoshop file format for several reasons; It's proprietary, not publicly documented, and very poorly supported by available libraries with commercial software friendly license terms. And it also does not store all the information we wish to store. (Hand drawn layer names, for example.)

Tiff is extremely well supported by the publicly available libtiff, and it has friendly license terms. Tiff is well documented, broadly supported by other applications, and is nicely extensible. This document assumes the reader is familiar with both libtiff and the tiff file format. (These can be found at; http://www.remotesensing.org/libtiff/)

Alias Sketchbook Pro Tiff Files

Sketchbook V1.1.1 and earlier stores its layers in a Tiff file using only

standard tags that are supported by libtiff. It does, however hijack some less commonly used tags for its own purposes, but only when the file is clearly identified as an Alias Multi Layer Tiff file in the SOFTWARE tag.

Later versions of Sketchbook will use a custom tag to store exactly the same data. This tag number is 50784 (decimal), and is registered with Adobe. We call it TIFFTAG_ALIAS_LAYER_METADATA. Version 1.2 of Sketchbook will write the metadata into the original HOST_COMPUTER and MODEL tags (as described below) as well as the new ALIAS_LAYER_METADATA tag. On reading, versions of Sketchbook after 1.1.1 will look at the new tag first, and if it is not present, will fall back on the old hijacked tags. Versions Of Sketchbook after V1.2 will write only the new tag. (As of this writing, Sept 27, 2004, the current version of Sketchbook is 1.1.1.)

A Sketchbook layer stack is fairly simple - the layers are all combined with a simple "over" blend equivalent to using an OpenGL blend function of (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).

An Alias Multi-Layer Tiff file consists of a composite image, possibly one or two reduced resolution versions of that composite image, and a layer stack. A layer stack consists of a background color, and an ordered collection of one or more image layers. Each image layer consists of a single 4-channel RGBA image of the layer (the alpha is associated - which is to say that the RGB channels are premultiplied by the alpha channel), and 1 or more auxiliary images. (each image is stored in its own SUBIFD.) The first auxiliary image for a layer is a hand drawn layer name. Future versions of Sketchbook will store several more single channel auxiliary images for masks, visibility channels etc. The layers in the layer stack are ordered from the bottom of the layer stack to the top.

In the Tiff file, Sketchbook stores a single page - in this image goes the composite of all the visible layers in the layer stack. This image is primarily for the consumption of other applications - Sketchbook ignores this image when reading Alias multi-layer tiff files. In addition to this single image is a collection of SUBIFDs in which thumbnails and layer images are stored. The first 0, 1, or 2 SUBIFDs (as indicated in a metadata tag on the main image) are reduced resolution versions of the composite image. If present, the first will be a large thumbnail sized version (larger dimension will be 256 pixels). If present, the second will be a roughly screen sized version - this allows an application to quickly load and display a fitted-to-view version of the image while proceeding to read the layers. This is especially useful with very large images. Both of these will be marked as reduced resolution images using the SUBFILETYPE tag, specifically setting it to FILETYPE_REDUCEDIMAGE. Subsequent SUBIFDs are layer images or auxiliary layer images.

Composite Image Tags

The SOFTWARE tag will be set to "Alias MultiLayer TIFF V1.1". If this tag is not set like this, Sketchbook will assume it's just an ordinary Tiff, and treat it as such. Note: Because of a rather nasty bug in the Windows file system explorer (it will corrupt all the SUBIFDs if you try to change file metadata like author etc), sketchbook saves the composite image with a strip size of 256 lines. If, on reading, the strip size is other than this, Sketchbook will assume the SUBIFDs and the layers stored in them have been corrupted by this bug in Windows, and ignore them.

TIFFTAG_HOSTCOMPUTER and TIFFTAG_ALIAS_LAYER_METADATA (V1.2 and later) will

be set to an ASCII string formatted as follows;

"%03d, %03d, %08x, %03d, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000"

The fields are, in order; LayerCount, CurrentLayer, BackgroundColor, ReducedImageCount. The remaining fields are reserved and must be 0.

These fields are defined as follows;

The channel ordering of the composite image and the two reduced resolution images is RGBA. The channel ordering of the layer images is BGRA, and they are stored lower-left origin, 8 bit u_int per/channel (32 bit per pixel) with the RGB channels premultiplied by the A channel.

Layer Tags

Each layer image has some meta-data stored on it in various tags as follows;

The position (in pixels) of the lower left corner of the layer (relative to the lower left corner of the composite image) is on the XPOSITION and YPOSITION tags.

The size of the layer is on the IMAGEWIDTH and IMAGEHEIGHT tags. Note that a layer can be larger or smaller than the overall composite image.

The PAGENAME tag will have an ASCII layer name in it.

The TIFFTAG_MODEL tag and the TIFFTAG_ALIAS_LAYER_METADATA (V1.2 and later)

tag will have some layer metadata formatted in as ASCII string as follows; "%05.3f, %02x, %1d, %1d, %1d, %d, %d, %d, %d, %d". The fields are, in order; LayerOpacity, LayerFillColor, LayerVisible, LayerLocked, LayerNameImagePresent, VisibilityChannelCount, MaskLayerCount, Reserved1, Reserved2, Reserved3.

These fields are defined as follows;

- LayerOpacity - floating point number from 0.0 to 1.0. The layer's

         overall opacity is modulated by this number - 0.0 indicating the
         layer will be completely invisible, and 1.0 indicating it is fully
         opaque (where its per-pixel alphas are 1.0).

- LayerFillColor - hex coded 32 bit color value, channel order is
         ARGB. All pixels outside the bounds of the layer image are
         assumed to be this color. Usually 0.

- LayerVisible - 0, or 1. Boolean indicating whether the layer is

visible or not. (1 = Visible)

- LayerLocked - 0 or 1. Boolean indicating whether the layer is

         locked or not. With Sketchbook the layer lock locks everything
         about a layer - it's name, opacity, and all its pixels. (1 =
         Locked)

- LayerNamePresent -- 0 or 1. Boolean indicating that the next

         SUBIFD is an image containing a hand-written layer name.
         (1 = Layer Name image is present in the nexty SUBIFD.)

- VisibilityChannelCount - Indicates the following n SUBIFDs (after
         the LayerName) are single channel images with unassociated alpha
         channels in them.

- MaskLayerCount - Indicates the following n SUBIFDs (following the
         LayerName and 0 or more Visibility Channels) are single channel
         mask layers.

         When present, both the mask and visibility SUBIFDs will have a
         MODEL tag on them with Opacity, FillColor, Visible, Locked, and
         Active fields (and 4 reserved fields) formatted as follows;
         "%05.3f, %02x, %1d, %1d, %1d, %d, %d, %d, %d".

         The mask and visibility channels are not stored as extra samples
         on the RGBA layer image for several reasons -- mainly performance.
         They are often not present, often with different bounds than their
         corresponding layer image, and are stored as seperate images
         internally in Sketchbook -- Combining them with the RGBA channels
         at save time and seperating them at load time would be wasteful
         both in terms of memory and CPU cycles.

- Reserved1, Reserved2, Reserved3 - reserved, must be 0;

Compression & Other Notes
-------------------------

Alias Sketchbook compresses the composite image, and the reduced resolution
images with LZW, and uses ADOBE_DEFLATE for the layer images.

Sketchbook tends to write images in strips of 256 rows. (Except the
screen-sized
reduced resolution image is written as one strip.)

As discussed above, Sketchbook Version 1.1.1 and earlier use only the HOST_COMPUTER

and MODEL tags. Version 1.2 will write both a new custom ALIAS_LAYER_METADATA tag

and the old tags for backwards compatibility. All future versions (1.2 and later)

will read the new tag first, and if it's not present will fall back on the old tags.

Versions of Sketchbook after 1.2 will write only the new custom tag, but will continue

to support reading the old tags.

Disclaimer & Copyright

This document is Copyright (C) Alias Systems Corp. Permission is given to reproduce

this document whole, and without change.

This document is provided as-is, with no warranty of any kind, and is

subject to change without notice.

Software Architect,

Alias SketchBook Technical Lead.

-- Always do the right thing. This will gratify some people and astonish the rest. -- Mark Twain.