File Size Problem From Single Page Tiffs to Multiple Page Tiff

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
wkmiu
Posts: 3
Joined: 2016-04-12T07:56:58-07:00
Authentication code: 1151

File Size Problem From Single Page Tiffs to Multiple Page Tiff

Post by wkmiu » 2016-04-12T08:38:58-07:00

Hi everyone,

I am now study how to save many single page tiff to a mutiple page tif in.NET
Below is the code I used:

For the 26 single page tiff, they are color tif file

Code: Select all

             using (MagickImageCollection collection = new MagickImageCollection())
                {
                    for (int i = 0; i < 26; i++)
                    {
                        MagickImage img = new MagickImage(i + ".tif");
                        collection.Add(img);
                    }

                    collection.Write("out.tif");
                   
                }
It does convert to a mutiple page tiff. However, the size of the mutiple page tif is much larger than the 26 single page tif file.
For each single page tif file, the file size is around 300-400KB, total size of 26 tif is around 8MB
But the file size of the output mutiple page 600Mb.

I tried to use Group4 Compression, it can make the output mutiple page tiff to around 7MB.
But it turns the image into black and white and the conversion time is so much longer (over 90s).

Another Compression Method I tried is LZW, it is faster but still the output file size is around 100MB


Is it the right way to convert single page tiff to mutiple page tiff?

What are the factors contributing to the large file size of the multiple page tiff?

And what are the possible solutions to
1. Make the output file size become small
2. Keep the original color
3. Make the conversion process faster

Finally, I upload an image of the metadata of the single page tif image.
https://dl.dropboxusercontent.com/u/89484328/19.png
Last edited by wkmiu on 2016-04-12T23:50:03-07:00, edited 1 time in total.

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

Re: File Size Porblem From Single Page Tiffs to Multiple Page Tiff

Post by snibgo » 2016-04-12T08:52:13-07:00

Your single tif image has over 6 million pixels, stored in 330,00 bytes. So it is compressed. "identify -verbose 000019.tif" will tell you the compression method.
snibgo's IM pages: im.snibgo.com

wkmiu
Posts: 3
Joined: 2016-04-12T07:56:58-07:00
Authentication code: 1151

Re: File Size Porblem From Single Page Tiffs to Multiple Page Tiff

Post by wkmiu » 2016-04-12T23:49:07-07:00

C:\Program Files\ImageMagick-6.9.3-Q16>identify.exe -verbose 000019.tif
Image: 000019.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 2487x3486+0+0
Resolution: 300x300
Print size: 8.29x11.62
Units: PixelsPerInch
Type: TrueColor
Base type: TrueColor
Endianess: LSB
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 8669682
Red:
min: 0 (0)
max: 255 (1)
mean: 249.218 (0.977325)
standard deviation: 24.6967 (0.0968499)
kurtosis: 41.9218
skewness: -6.11314
entropy: 0.24041
Green:
min: 0 (0)
max: 255 (1)
mean: 235.927 (0.925202)
standard deviation: 44.2119 (0.17338)
kurtosis: 14.4669
skewness: -3.56317
entropy: 0.345807
Blue:
min: 0 (0)
max: 255 (1)
mean: 229.844 (0.90135)
standard deviation: 50.9924 (0.19997)
kurtosis: 7.36235
skewness: -2.56874
entropy: 0.359936
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 238.33 (0.934626)
standard deviation: 41.4923 (0.162715)
kurtosis: 15.631
skewness: -3.73447
entropy: 0.315384
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 2487x3486+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Orientation: TopLeft
Properties:
comment:
date:create: 2016-04-13T14:40:42+08:00
date:modify: 2016-03-30T14:57:14+08:00
jpeg:sampling-factor: 2x2
signature: 3240d3ddeb7498253b119a8ebd8a900c4f6c07604e491410a7b8ba2ec55c9586
tiff:alpha: unspecified
tiff:artist:
tiff:document: DN0P 0000000013000000001600000.----!--1100
tiff:endian: lsb
tiff:make:
tiff:model:
tiff:photometric: YCBCR
tiff:rows-per-strip: 3486
tiff:software:
tiff:timestamp: 2016:03:30 14:57:13
Artifacts:
filename: 000019.tif
verbose: true
Tainted: False
Filesize: 337KB
Number pixels: 8.67M
Pixels per second: 50.4MB
User time: 0.172u
Elapsed time: 0:01.172
Version: ImageMagick 6.9.3-8 Q16 x64 2016-04-10 http://www.imagemagick.org
-----------------------------------------

From AsTiffTagViewer, the compression method is JPEG TechNote #2

SubFileType (1 Long): Zero
ImageWidth (1 Short): 2497
ImageLength (1 Short): 3498
BitsPerSample (3 Short): 8, 8, 8
Compression (1 Short): JPEG Technote #2
Photometric (1 Short): YCbCr
DocumentName (58 ASCII): DN0P 0000000007000000000300000...
ImageDescription (80 ASCII): ...
Make (14 ASCII):
Model (21 ASCII):
StripOffsets (1 Long): 8
Orientation (1 Short): TopLeft
SamplesPerPixel (1 Short): 3
RowsPerStrip (1 Short): 3498
StripByteCounts (1 Long): 276914
XResolution (1 Rational): 300
YResolution (1 Rational): 300
PlanarConfig (1 Short): Contig
ResolutionUnit (1 Short): Inch
Software (24 ASCII):
DateTime (20 ASCII): 2016:03:30 14:57:07
Artist (9 ASCII): sysadmin
JpegTables (574 Undefined):
YCbCrSubsampling (2 Short): 2, 2

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

Re: File Size Problem From Single Page Tiffs to Multiple Page Tiff

Post by snibgo » 2016-04-13T04:57:15-07:00

Yes, the TIFF files are compressed with the JPEG method. When writing this won't happen by default because jpeg is lossy. If you want it, you have to ask explicitly: "-compress jpeg".
snibgo's IM pages: im.snibgo.com

wkmiu
Posts: 3
Joined: 2016-04-12T07:56:58-07:00
Authentication code: 1151

Re: File Size Problem From Single Page Tiffs to Multiple Page Tiff

Post by wkmiu » 2016-04-13T20:17:37-07:00

As I mentioned before, I tried several compression methods but the output size is not satisfactory.

I use the following code to do the JEPG compression, the file size of the output multiple page tiff is around 600MB.
JPEG2000 also return similar file size result
using (MagickImageCollection collection = new MagickImageCollection())
{
for (int i = 0; i < 26; i++)
{
MagickImage img = new MagickImage(i + ".tif");
img.CompressionMethod = CompressionMethod.JEPG;
collection.Add(img);
}
collection.Write("out.tif");
}

Post Reply