Setting TIFF tags

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
mmuratet

Setting TIFF tags

Post by mmuratet »

Greetings
Are there any methods in Magick++ for getting/setting TIFF tags? I don't see them in the docs and came up empty searching the forum.
Thanks
Mike
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Setting TIFF tags

Post by magick »

It would helpful to know which TIFF tags you would like to set.
mmuratet

Re: Setting TIFF tags

Post by mmuratet »

I'd like to be able to set the tags associated with gray scale images per the Tiff 6 spec (the latest one?): 256, 257, 258, 259, 262, 273, 278, 279, 282, 283, 296 (all values decimal). I have some sample images of the format I'd like to create and they also set 277 and 284.

While we're talking about it, is there a way to fool the Image constructor into creating a gray scale image by setting only a single color (e.g., map string = "R") and manipulating the tags?

Thanks

Mike
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Setting TIFF tags

Post by magick »

You can certainly set some of these TIFF tags by manipulating your image. TIFF Tag 256 and 257 are controlled by the image size, 258 by the image depth. Set 259 by specifying the image compression. However, to get the most control over these tags you probably want to bypass ImageMagick altogether and instead use the TIFF API, see ftp://ftp.remotesensing.org/libtiff/.
JimShip@sbcglobal.ne

Re: Setting TIFF tags

Post by JimShip@sbcglobal.ne »

I am scanning old film and want to set the date/time to the original date/time of the picture. I can scan to jpeg files and there are lots of ways to set the time/date, but I want to scan to uncompressed tiff files to preserve the quality of the scan. When I run convert on a jpeg file to tiff file, the date/time stamp in the new tiff file is the current time/date, and not the original time/date from the jpeg file.

How can I set/change the tiff date/time stamp in my scans from imagemagick or some other program (without writing a program myself)? Hopefully in batch mode.

Thanks,
Jim Shipman
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Setting TIFF tags

Post by magick »

It is standard practice to modify the file time when a new file is created. We could add an option that preserves the file time. In the mean-time use the touch utility (Linux / Unix) to preserve the file times.
JimShip@sbcglobal.ne

Re: Setting TIFF tags

Post by JimShip@sbcglobal.ne »

This doesn't do what I want. I need to set the actual TIFFTAG DATETIME inside the file to the "Shooting date/time". Changing the file timestamp does nothing for photos.

I did try this and it does set the modification time when I used identify, but I don't see how to change the creation time.

I'm confused now about how much of the data presented by identify -verbose comes from tags inside the file and how much comes from analysis of things like the file modification time etc.

Jim
JimShip@sbcglobal.ne

Re: Setting TIFF tags

Post by JimShip@sbcglobal.ne »

Maybe it would help if you all knew what I am trying to accomplish.

I am scanning in negatives that I have carefully preserved going all the way back to the early 1970's.

I was scanning them into jpeg files and then used the FSpot "adjust time" function to change the EXIF date/time data inside the file. When I would then import those pictures into picasa (google) then picasa sorted the images by the exif date/time field.

I then switched to saving the scanned images in uncompressed tiff format to preserve quality as most of the images require a good bit of tweeking to bring them back from their 1970's degradation. However, when I scan to a tiff format I am no longer able to set the date/time tag inside the tiff file, and picasa puts everything I scan in scan date/time order instead of "shooting date/time" order.

I see that the tiff spec. has a TIFFTAG DATETIME field and I just want to set it to the actual shooting date/time of the scanned image.

Thanks for any help you can give me,
Jim Shipman
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Setting TIFF tags

Post by fmw42 »

there must be some non-ImageMagic tools available for setting TIF fields. have you googled for it?
JimShip@sbcglobal.ne

Re: Setting TIFF tags

Post by JimShip@sbcglobal.ne »

Yes! I haven't found anything short of writing my own program using the libtiff or perltiff. This seems to me to be pretty basic function. I don't understand why it should be so hard.

<opinion>
The tiff format is just a special purpose container used to hold representations of a "Moment in Time" in the form of an image. This container has a label on it with a bunch of fields that pertain to recreating that "Moment in Time" as in image (TIFFTAGS -- color space, xres, yres, ...), but it also has fields that contain data about the actual "Moment in Time" itself (TIFFTAG for DATETIME (Shooting time), fstop, exposure speed, asa, etc. -- should also have other fields like location, people, etc., but that can wait). These fields are not related to the physical recreation of an image and thus can't be calculated. Convert when it changes the physical container (tiff->jpeg or jpeg->tiff for example) does a good job in filling in the physical fields, but the data about the actual "Moment in Time" is in many respects even more important and convert should do its best to also transfer this data the new container (whenever possible). This data seems to be lost when convert changes formats.

Also:
Because "Moments in time" can come from non-digital sources where these data were recorded in other formats (in ink on the back of a picture, for example) convert should provide a means to be able to create/edit these fields also. The defined fields should be used. Just put it in the "Comment" field is not a solution because it is not portable.
</opinion>

Jim
wlarmon

Re: Setting TIFF tags

Post by wlarmon »

Because "Moments in time" can come from non-digital sources where these data were recorded in other formats (in ink on the back of a picture, for example) convert should provide a means to be able to create/edit these fields also. The defined fields should be used. Just put it in the "Comment" field is not a solution because it is not portable.
ImageMagick is great at what it does do, but sometimes isn't too good at dealing with EXIF type tags. It does pass most of them on, but some get left behind. And ImageMagick doesn't let you set many tags.

I'm also in the process of dealing with scanned images. I deal with the tags issue by using Phil Harvey's EXIFTool to fix any missing tags. I'm using PerlMagick and the Perl version of EXIFTool. When I'm processing an image, my code uses EXIFTool to grab all the fields from the original TIFF that I know won't get passed on with ImageMagick. After I write the image, after transforming it with Imagemagick, my script then uses EXIFTool to fix up any EXIF fields that need fixing. (The ImageMagick documentation mentions that this is an issue and suggests using ExifTool for this purpose.)

I also care about the timestamps. My solution is to put the date information in the description field of the original scanned TIFF image's comment field (along with the rest of the caption) when I'm doing my initial PhoitoShop touchup and not worry about putting it in the EXIF field. But when I write the resized JPEG that PerlMagick created from the TIFF, I use EXIFTool to put the timestamp in the proper EXIF fields in the JPEG. This is close enough for my needs. I could use EXIFTool to update the timestamp fields in the original TIFF file, but, thus far haven't felt the need.

Get EXIFTool from http://www.sno.phy.queensu.ca/~phil/exiftool/
Post Reply