Page 1 of 1

Multi Layer Tiff to PNG, getting crazy..

Posted: 2018-09-11T14:59:51-07:00
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

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

Posted: 2018-09-12T21:49:21-07:00
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");
}

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

Posted: 2018-10-07T12:15:50-07:00
by lucd
THANKS dlemstra, that does the job !!

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