Resize of a multi layer TIFF failed

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
Harald
Posts: 13
Joined: 2018-07-26T05:59:40-07:00
Authentication code: 1152

Resize of a multi layer TIFF failed

Post by Harald »

Original TIF: 1330x1380 px
New TIF: 410x426 px

It seems easy to resize a TIFF file with ImageMagick:
convert Original.tif -resize 410x426 New.tif

Loading with an image viewer everything seems OK.
But loading in Photoshop shows me a cropped picture.
I see only the upper left corner.
It has cropped the upper left corner with 410x426 px.
https://imageshack.com/i/poMTWLhPj

It is a multi layer TIF. Is this the problem?
Because I also cannot "-layers merge".

Thank you for help!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resize of a multi layer TIFF failed

Post by snibgo »

Your linked image, test1.jpg, was clearly not make by your command which makes New.tif.

If you don't link to your actual input(s) and output(s), there is little we can say to help.

You should also say what version of IM you use, on what platform.
snibgo's IM pages: im.snibgo.com
Harald
Posts: 13
Joined: 2018-07-26T05:59:40-07:00
Authentication code: 1152

Re: Resize of a multi layer TIFF failed

Post by Harald »

I use the current Version of IM: ImageMagick-7.0.8-Q16-HDRI

Original TIF: https://www.dropbox.com/s/2enkmvc93wwx6 ... l.tif?dl=0
New TIF: https://www.dropbox.com/s/zd0dlp27njuwh2p/New.tif?dl=0

I also not understand, why the new smaller TIF has bigger file size than the original.

Thank you for your help!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

Your Original TIFF may be malformed since no file size is showing for other than the first layer/page. This may be due to Photoshop only saving the first or layer file size (or total file size?) in a place where ImageMagick can located it. The other layers may have that information stored in a proprietary tag or profile.

identify original.tif
original.tif[0] TIFF 1330x1380 1330x1380+0+0 8-bit CMYK 8169170B 0.030u 0:00.039
original.tif[1] TIFF 1330x1380 1330x1380+0+0 8-bit CMYK 0.000u 0:00.000
original.tif[2] TIFF 276x323 276x323+199+407 8-bit CMYK 0.000u 0:00.000

After resizing, those layers now show a proper file size, perhaps because ImageMagick stores that information for each layer/page where it can find it.

identify New.tif
New.tif[0] TIFF 410x425 410x425+0+0 8-bit CMYK 10.2503MiB 0.030u 0:00.029
New.tif[1] TIFF 410x425 410x425+0+0 8-bit CMYK 10.2503MiB 0.000u 0:00.000
New.tif[2] TIFF 364x426 364x426+262+537 8-bit CMYK 10.2503MiB 0.000u 0:00.00

I also note that your first layer is LZW compressed, but the other two layers are RLE compressed.

Note also that XB is not the same as XBi. The first is decimal (KB=1000B) and the second is binary (KBi=1024B). See the table at https://en.wikipedia.org/wiki/Byte
Harald
Posts: 13
Joined: 2018-07-26T05:59:40-07:00
Authentication code: 1152

Re: Resize of a multi layer TIFF failed

Post by Harald »

Thank you for this explanation.

So after resizing, the layers show a proper file size.
But why has the third layer a different pixel size?
New.tif[2] TIFF 364x426

It seems that ImageMagick cannot work with the Original.tif.
Because I also cannot "-layers merge".

What can I do?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

The 3rd layer/page of your input is not the same pixel size as the other two layers. So the output will have a different size for the 3rd layer/page. ImageMagick -resize will resize but keep the aspect ratio. If you want all 3 layers/pages to be the same final size then you either need to 1) add ! to the resize, but that will distort the results, 2) pad the result or 3) crop the result after adding ^ to the resize arguments. See https://www.imagemagick.org/script/comm ... p#geometry

I do not understand what you mean by you cannot do "-layers merge"? What happens? Do you get error messages? It works fine for me to create a final png file

Code: Select all

convert Original.tif -layers merge +repage tmp.png
Harald
Posts: 13
Joined: 2018-07-26T05:59:40-07:00
Authentication code: 1152

Re: Resize of a multi layer TIFF failed

Post by Harald »

Thank you for your help!

Merging the layers did not work for creating a TIF file.

Code: Select all

convert Original.tif -layers merge +repage New.tif
Maybe my original TIF is malformed. I don't know.
Back to my main problem. I only want to resize my TIF files. But this is not working:

Code: Select all

convert Original.tif -resize 410x426 New.tif
And my biggest problem is the quality.
I got not the same quality with ImageMagick as with Photoshop.

Do you have any ideas?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

Looking carefully at your Original.tif layers, I see that the first layer is already the merged/flattened layer from the other two layers.

I don't see any quality issues when using IM 6.9.10.8 Q16 Mac OSX using LIBTIFF, Version 4.0.9. Have you checked your libtiff version and upgraded to the most current?

Here are the results of my tests. The first test simple resizes all layers/pages. The second just uses the first flattened layer. The third does the same as the second but converts to sRGB using a profile. Only one profile is needed since your CMYK TIFF already has a CMYK profile imbedded.

Code: Select all

convert Original.tif -resize 410x426 fred_new1.tif
http://www.fmwconcepts.com/misc_tests/t ... d_new1.tif

Code: Select all

convert Original.tif[0] -resize 410x426 fred_new2.tif
http://www.fmwconcepts.com/misc_tests/t ... d_new2.tif

Code: Select all

convert Original.tif[0] -profile /Users/fred/images/profiles/sRGB.icc -resize 410x426 fred_new3.tif
http://www.fmwconcepts.com/misc_tests/t ... d_new3.tif

Do my results look OK?
Harald
Posts: 13
Joined: 2018-07-26T05:59:40-07:00
Authentication code: 1152

Re: Resize of a multi layer TIFF failed

Post by Harald »

Thank you Fred for your help!

Loading with an image viewer all your 3 examples look OK.
But loading in Photoshop shows me a cropped picture.
It has cropped the upper left corner with 410x426 px.
https://imageshack.com/i/poMTWLhPj

Question to the version:
You did use IM 6.9.10.8 Q16 on Mac OSX
I use IM 7.0.8-Q16-HDRI on Win 7
I cannot found a LIBTIFF library.
Should I change the version?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

cannot found a LIBTIFF library.
It should be listed when you do
magick -list format
On my system, I get

TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.9)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

It looks like a bug to me. But is it in IM or Photoshop? I will report this on the Bugs forum.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

I do not know if layered tiffs have a flattened layer like PSD files. It seems that this one does. But ignoring the flattened layer [0] and merging seems to work for me.

convert original.tif[1-2] -layers merge +repage -resize 410x426 result.tif

When I open result.tif in PS, it looks fine and has only one layer.
Harald
Posts: 13
Joined: 2018-07-26T05:59:40-07:00
Authentication code: 1152

Re: Resize of a multi layer TIFF failed

Post by Harald »

I got it. Thank you!

I have a question about the quality. I use in Photoshop for downcscaling "Bicubic Sharper".
In IM I use "-filter Lanczos". But it seems that the Photoshop image is sharper.

What can I do to get it a little bit sharper in IM?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resize of a multi layer TIFF failed

Post by fmw42 »

Try using -filter catrom or one of the other filters and/or the expert options. See the reference below from Nicolas Robidoux.

Otherwise, you will need to add some unsharp masking, which I think Photoshop has built into their bicubic filter.

See
https://www.imagemagick.org/Usage/filter/
https://www.imagemagick.org/Usage/filter/#photoshop
https://www.imagemagick.org/Usage/filter/nicolas/
https://www.imagemagick.org/script/comm ... hp#unsharp
Post Reply