Create multipage TIFs

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
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Create multipage TIFs

Post by Jossie »

Good morning,

I have the following plan concerning scans of my slides with two different software:
Scans from software A are better than scans from software B. However, the tools for image processing provided by software B are better than the tools from software A. So my aim is to use software A for scanning and B for image processing. So I have to convert the raw data from software A to look like the raw data from software B.

I have scans using A and B of a slide with the same pixel dimensions. I have managed to extract from both of these the RGB and the IR image as single-page tifs.

My aim is to create a multipage tif (required by B) from two input tifs extracted from A, being the RGB-image (3x16bit pixels) and the IR-image (16bit B&W tif).

I use

Code: Select all

convert RGB-image.tif IR-image.tif new_multipage.tif
Then I copy all metadata from the file created from software B to this newly created multi-page tif, to fool software B. And here comes the problem:

I can open the original output tif from software A with imageJ and it looks fine. However, if I open the artificilly created multipage tif the image is not correct (mainly noise). Although both multipage tifs should have the same structure and metadata, one is readable and one is not. And if I open the multipage tif with software B, I correctly see the RGB-image, but the IR-image is completely black. So obviously somethings is going wrong with my trick.

What do I do wrong? I would very much appreciate any hints.

Many thanks in advance and best wishes for the Easter Holidays,

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create multipage TIFs

Post by snibgo »

Jossie wrote:What do I do wrong?
I can't guess.

I suggest you link to example scans from A and B. Then someone can look at B, and perhaps figure out what processing needs to be done to A.

How do you copy the metadata? With exiftool? What command(s)?
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Create multipage TIFs

Post by Jossie »

Wow, that is a fast reply! Thank's a lot!

The images are too large to attach (190MByte, and 60MByte). Creating small versions may take a while. However, each individual input (RGB and IR) looks perfectly okay when opened with various software (imageJ, photoshop, IrfanView ...). So I assume that something went wrong with the multipage tif. Are there any options with the convert command which I missed?

Yes, metadata are copied with exiftool (the GUI, to be exact, using "copy metadata from a single file").

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create multipage TIFs

Post by snibgo »

If you can't upload the files somewhere, can you:

Code: Select all

identify -verbose x.tiff
Paste the results here, between [ code ] and [ /code ].

Do this for a file that B is happy with, and files scanned by A. Perhaps also for the multi-page file that you made that fails with B.
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Create multipage TIFs

Post by Jossie »

Okay, I did that and compared the output.

First difference encountered is the Endianess: MSB for the file liked by B, and Endianess: LSB for my fake multipage.tif.

The channel statistics is also different, which I expect, since the data are different.

In both cases I see the RGB-image on page 1 with 3x16 bit, and the greyscale-image on page 2 with 1x16bit, which is correct.

So the endianess seems to be the issue. Can I influence this in imagemagick?

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create multipage TIFs

Post by snibgo »

Try "-define tiff:endian=msb" (or lsb). See http://www.imagemagick.org/script/comma ... php#define

You might check the mean value of the greyscale image. I suppose the image is mostly black with white dust specks (or mostly white with black dust specks), so the mean value should be close to zero (or 100%).
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Create multipage TIFs

Post by Jossie »

Unfortunately settung the endianess to MSB did not help.

Yes, the IR image is white with just some black dust specks. This is indicated by the mean gray value of 49000 for the original from B and 52000 for my artifical image. But the level should be detected by B automatically. If I extract the IR-channel from the artificial image with imagemagick I get the identical image back that I put in.

So there is no obvious reason, why imageJ does not display the two pages correctly neither why B does not have the correct IR-channel.

I made an additional simple test, having nothing to do with A or B. I combined the gray-scale Images for R and G into a 2-page TIF with imagemagick and it worked. The result is correctly displayed in imageJ. However, if I use as the first image an RGB image (3x16bit), the second page is not displayed in imageJ! However, I can extract the second page with imagemagick. Maybe there is a problem with imageJ ... (and with B?) ...

Many thanks for your help!

Hermann-Josef
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Create multipage TIFs

Post by snibgo »

It's worth checking that "-define tiff:endian=msb" has worked. "identify -verbose" should contain " Endianess: MSB" for both images in the TIFF.

You could "exiftool -s2 -all -b -X -fXMP:XMP x.tiff" for the files. These will show how the images are actually stored in the file (bits per sample etc). "identify -verbose" shows how the image has been read in, which may not be the same.

Beyond that, I'm out of ideas.
snibgo's IM pages: im.snibgo.com
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Create multipage TIFs

Post by Jossie »

Yes, I had already done these checks. Sorry, I should hvae mentioned that: Both pages have the desired endiness. Also with EXIFtool GUI I had seen that the bits per pixel are set correct for both pages.

I will try to make further experiments. Perhaps I come across something which sheds light on the Problem.

Many thanks for your help!

Hermann-Josef
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create multipage TIFs

Post by fmw42 »

It might help if you provide your version of IM and platform and version of libtiff. Perhaps they need upgrading
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Create multipage TIFs

Post by Jossie »

The IM-Version is 6.8.9-7 Q16 (2014-09-15). Where do I find the libtiff version?

I use Win7 on a 64bit System with 24GByte of RAM.

I just found out that with my exiftool command not all tags had been copied. Especially one XMP-tag, holding all the setup for B, was not copied. I have to find out, how to copy such a (non-standard) tag. This might explain the problem.

Hermann-Josef
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create multipage TIFs

Post by fmw42 »

TIFF (photoshop) proprietary tags make things had to do with non-Photoshop software.
Jossie
Posts: 25
Joined: 2015-01-31T03:45:52-07:00
Authentication code: 6789

Re: Create multipage TIFs

Post by Jossie »

Sorry, but I do not understand what you mean. I do not use PhotoShop, but the tag is written by software B and has the structure XMP-Name_B:ScanFrames=' ... ', where the dots stand for a long text, holding information about the setup of the software.

Hermann-Josef
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create multipage TIFs

Post by fmw42 »

XMP tag is a Photoshop specific tag. Perhaps your software B is not writing it correctly.
Post Reply