Multi Layer Tiff to PNG, getting crazy..

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
lucd
Posts: 3
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Multi Layer Tiff to PNG, getting crazy..

Post by lucd »

hello,

thanks in advance for your help.

i am converting various files to 400x400px png, and all ok with any format , except mutlilayers tiffs

here is a sample file causing problem https://pimdevstor01.blob.core.windows. ... 613037.tif

from this file, i get a png of 43mb, while the usual size of those 400px pngs is < 250 kb
this tiff has 2 layers, if i flatten it in photoshop, then process it, i get a very correct png of 100kb

in magicknet, i tried everything, without success
note that those settings work perfectly with psd multlayers > 300mb, even without the flatten()

Code: Select all

       
       		var content = fileRequest.FileStream;
          
                MagickReadSettings settings = new MagickReadSettings();
                settings.Density = new Density(600, 600, DensityUnit.PixelsPerInch);
                settings.FrameIndex = 0;
                
                _magickImageCollection = new MagickImageCollection(content, settings);

                IMagickImage image = _magickImageCollection.Flatten();
this is the png file that I am getting, 43mb https://pimdevstor01.blob.core.windows. ... 37.tif.png
If i open it in irfanview and save it without any modification, i get a file af a few kb...

Any idea ?

thanks a lot,

Luc
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Multi Layer Tiff to PNG, getting crazy..

Post by dlemstra »

The layers of a tiff image are stored inside the `tiff:37724` profile. You will need to remove that yourself before you save the image:

Code: Select all

MagickReadSettings settings = new MagickReadSettings();
settings.Density = new Density(600, 600, DensityUnit.PixelsPerInch);

using (var image = new MagickImage(@"i:\2613037.tif", settings))
{
    image.Resize(400, 400);
    image.RemoveProfile("tiff:37724");
    image.Write(@"i:\test.png");
}
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
lucd
Posts: 3
Joined: 2018-09-11T14:50:41-07:00
Authentication code: 1152

Re: Multi Layer Tiff to PNG, getting crazy..

Post by lucd »

THANKS dlemstra, that does the job !!

Sorry for late answer, i saw your reply only today.
Post Reply