Extract RGBI image from multipage TIFF

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

Your original and my two images look identical in Photoshop and Imagemagick says they are are identical.

compare -metric rmse raw-from-vuescan.tif tmp_unspec.tif null:
0 (0)

compare -metric rmse raw-from-vuescan.tif tmp_unassoc.tif null:
0 (0)

I will look at the meta data tomorrow and see if I see any differences.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

The only difference I see between your original and my tif (transparency unspecified) via IM identify -verbose, is as follow:

Yours:

Code: Select all

    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:make: Nikon
    tiff:model: LS-5000
    tiff:photometric: RGB
    tiff:rows-per-strip: 1
    tiff:software: VueScan 9 x64 (9.5.67)

Mine:

Code: Select all

    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: RGB
    tiff:rows-per-strip: 1

So your file has only 3 lines added:

tiff:make: Nikon
tiff:model: LS-5000
tiff:software: VueScan 9 x64 (9.5.67)

Perhaps the last one showing the software as VueScan makes a difference?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

There are difference between the two files using EXIFTOOL. But I do not know what to make of that information.

Your file:

Code: Select all

exiftool -s -ee -g1 -u -n -D raw-from-vuescan.tif
---- ExifTool ----
    - ExifToolVersion                 : 8.71
---- System ----
    - FileName                        : raw-from-vuescan.tif
    - Directory                       : .
    - FileSize                        : 182402531
    - FileModifyDate                  : 2017:02:03 16:18:15-08:00
    - FilePermissions                 : 644
---- File ----
    - FileType                        : TIFF
    - MIMEType                        : image/tiff
    - ExifByteOrder                   : II
---- IFD0 ----
  254 SubfileType                     : 0
  256 ImageWidth                      : 5780
  257 ImageHeight                     : 3944
  258 BitsPerSample                   : 16 16 16 16
  259 Compression                     : 1
  262 PhotometricInterpretation       : 2
  266 FillOrder                       : 1
  271 Make                            : Nikon
  272 Model                           : LS-5000
  273 StripOffsets                    : (Binary data 37030 bytes, use -b option to extract)
  274 Orientation                     : 1
  277 SamplesPerPixel                 : 4
  278 RowsPerStrip                    : 1
  279 StripByteCounts                 : (Binary data 23663 bytes, use -b option to extract)
  280 MinSampleValue                  : 0 0 0 0
  281 MaxSampleValue                  : 65535 65535 65535 65535
  282 XResolution                     : 4000
  283 YResolution                     : 4000
  284 PlanarConfiguration             : 1
  285 PageName                        : Transparency
  296 ResolutionUnit                  : 2
  305 Software                        : VueScan 9 x64 (9.5.67)
---- ExifIFD ----
36868 CreateDate                      : 2017:01:30 17:28:10
---- Composite ----
    - ImageSize                       : 5780x3944

My file:

Code: Select all

exiftool -s -ee -g1 -u -n -D raw-from-vuescan_unspec.tif
---- ExifTool ----
    - ExifToolVersion                 : 8.71
---- System ----
    - FileName                        : raw-from-vuescan_unspec.tif
    - Directory                       : .
    - FileSize                        : 182370915
    - FileModifyDate                  : 2017:02:03 16:19:02-08:00
    - FilePermissions                 : 644
---- File ----
    - FileType                        : TIFF
    - MIMEType                        : image/tiff
    - ExifByteOrder                   : II
---- IFD0 ----
  256 ImageWidth                      : 5780
  257 ImageHeight                     : 3944
  258 BitsPerSample                   : 16 16 16 16
  259 Compression                     : 1
  262 PhotometricInterpretation       : 2
  266 FillOrder                       : 1
  273 StripOffsets                    : 8
  274 Orientation                     : 1
  277 SamplesPerPixel                 : 4
  278 RowsPerStrip                    : 3944
  279 StripByteCounts                 : 182370560
  282 XResolution                     : 4000
  283 YResolution                     : 4000
  284 PlanarConfiguration             : 1
  285 PageName                        : Transparency
  296 ResolutionUnit                  : 2
  297 PageNumber                      : 0 1
  318 WhitePoint                      : 0.3127000035 0.3289999963
  319 PrimaryChromaticities           : 0.6399999858 0.3300000132 0.300000012 0.600000024 0.150000006 0.05999999867
  338 ExtraSamples                    : 0
---- Composite ----
    - ImageSize                       : 5780x3944


In particular some large differences at

Yours: 254 SubfileType : 0
Mine: does not have this

Yours: 278 RowsPerStrip : 1
Mine: 278 RowsPerStrip : 3944

Yours: 279 StripByteCounts : (Binary data 23663 bytes, use -b option
Mine: 279 StripByteCounts : 182370560

Yours:
280 MinSampleValue : 0 0 0 0
281 MaxSampleValue : 65535 65535 65535 65535
Mine: has neither

Yours: has none of these
Mine:
297 PageNumber : 0 1
318 WhitePoint : 0.3127000035 0.3289999963
319 PrimaryChromaticities : 0.6399999858 0.3300000132 0.300000012 0.600000024 0.150000006 0.05999999867
338 ExtraSamples : 0
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

Try this:

Code: Select all

convert raw-from-vuescan.tif -define tiff:rows-per-strip=1 -define tiff:alpha=unspecified raw-from-vuescan_unspec.tif
When I view your original and this result in Photoshop, they look identical.

Possibly, when viewing both images in your VueScan, one has transparency off and the other has transparency on.

Imagemagick says the data is identical, since the compare gives a zero rmse metric value
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

What is your exact IM version and platform/OS? Perhaps you need an upgrade. Also what is your version of libtif? Maybe that needs updating?

I am on IM 6.9.7.6 Q16 and libtiff 4.0.6
koyglreg
Posts: 20
Joined: 2017-01-26T14:48:04-07:00
Authentication code: 1151

Re: Extract RGBI image from multipage TIFF

Post by koyglreg »

ImageMagick version 6.9.3-Q16. I'm on Windows 10 x64 and I don't know how to get the libtiff version.

To clarify, I'm trying to restore the "raw-extracted-with-imagemagick.tif" file to be identical to the "raw-from-vuescan.tif" file. So I don't need to do anything to "raw-from-vuescan.tif"; this file is already perfect and is what I'm trying to revert to.

I tried your command on the "raw-extracted-with-imagemagick.tif" file, but this had no effect in VueScan. It still looks washed out, as if it's more transparent than the original.

It's encouraging to hear that IM says the data is identical. I'll update my IM and see if that helps.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

convert -list format

will tell you your version of libtif for TIF files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

Here is my IM convert tif from your original.

http://www.fmwconcepts.com/misc_tests/r ... unspec.tif

Does that look correct in your software?

They look identical in Photoshop and my Mac Preview.
koyglreg
Posts: 20
Joined: 2017-01-26T14:48:04-07:00
Authentication code: 1151

Re: Extract RGBI image from multipage TIFF

Post by koyglreg »

I just downloaded it and looked at it in VueScan, and it looks fine.

I have libtiff 4.0.6.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

Does that mean your issue resolved?
koyglreg
Posts: 20
Joined: 2017-01-26T14:48:04-07:00
Authentication code: 1151

Re: Extract RGBI image from multipage TIFF

Post by koyglreg »

No, because like I said, the problem file is "raw-extracted-with-imagemagick.tif." This is the file that needs to open in VueScan without problems.

EDIT: I'll repost the link to this tiff: https://drive.google.com/file/d/0B9eUF3 ... NQbEE/view

This file was "messed up"/changed in IM, and I need to fix it. The "raw-from-vuescan.tif" file is just an example of what this file should look like before it was messed up. Thanks for the help.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

I do not understand. If my file opened fine in VueScan, then why is this not resolved. What else are you doing in IM to process the files, before converting to TIFF. If it is not the write to tiff, which I showed you how to do and you said it was fine, then it must be something else in your command line.

Please clarify further, since I am obviously missing something about your problem.

Are you able to open your files in Photoshop and do they look correct? Is the alpha channel turned on? If not, then does it look correct when the alpha channel is on (or off)?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

I went back to your example.tif image. First, I opened it in Photoshop and it only shows 1 layer. Nevertheless, I processed it as follows to extract the second layer and write it out as a new tif in imagemagick:

Code: Select all

convert example.tif[1] -define tiff:rows-per-strip=1 -define tiff:alpha=unspecified example1_im.tif
Here is the file:
http://www.fmwconcepts.com/misc_tests/example1_im.tif

Can you process this file in VueScan.

If I open it in Photoshop, it shows a (disabled) alpha channel that when enabled puts spots onto the image.
koyglreg
Posts: 20
Joined: 2017-01-26T14:48:04-07:00
Authentication code: 1151

Re: Extract RGBI image from multipage TIFF

Post by koyglreg »

Your example1_im.tif file has the same issue in VueScan, where it's too transparent.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Extract RGBI image from multipage TIFF

Post by fmw42 »

Sorry, I do not know what else to suggest.

Is there an example image that you have where you extracted the second layer using some tool that seems to work properly in VueScan? If so, post that input (2 layer image) and your extracted layer 2 image. Then I can try to compare it with my extracted layer 2 from the same input image.
Post Reply