Multipage issues

Hello,
I have a TIF which is 9 pages and ~10mb in size.

  1. Saving as Psd will make a 1.13GB Psd file which contains ONLY the last page of Tif, what’s wrong? 1.13GB and incomplete?

  2. Saving as Bmp will make 128mb file, saving as Tga the same 128mb, seems large, what am I missing?

  3. Saving as Gif or Bmp or Jpg or Png or Tga will only save the first page of Tif in result file, how to force it to have all pages in a single file? Of course height will be long.

  4. General question, which of these formats support multi pages in a single file like Tiff and Dicom?
    Psd Tga Png Gif Jpeg Bmp

Notes: When loading a multipage Tiff or Dicom image and save it as Tiff or Dicom, the resulting image will have the same multi pages from the source image, no any special load/save options or work is needed, this is great.

However, if we load a multipage Tiff or Dicom image and save it as other formats which has multipage classes (like Psd or Gif) this will not happen and resulting image is not multipage like source.

Hello
Source Tif file inside the project, I’ve got another error, simply run the project and you will see 2 bugs insde, thanks :slight_smile:

@australian.dev.nerds To help us understand and resolve your issue, please send us the sample TIF file that you are working with. We cannot create algorithms on demand, but we can assist you with using the Aspose.Imaging methods that are relevant to your task. You can find the instructions for manipulating images using Aspose.Imaging here: Manipulate Images in C#|Documentation. Some of the image formats that support multiple frames are Gif, Tiff, Psd, Dicom, Cdr, WebP, and Apng.

1 Like

Hello,
OK first run and test this sample which includes the sample multipage Tiff.
Bug 1: Saving it as Psd will cause exceptions.
Issue 2: Saving it as Bmp will make extra large file which is not normal.

There is also a strange issue when saving as Tga, very large size, sample to reproduce:

@australian.dev.nerds , we have checked your file and all works OK. You may use next code to convert tiff file to another multipage file:

using (TiffImage image = (TiffImage)Image.Load(@"c:\Users\USER\Downloads\Source.tif"))
            {                
                image.Save(@"c:\Users\USER\Downloads\result.psd", new GifOptions
                {
                    IsPaletteSorted = false,
                    DoPaletteCorrection = false,
                    MaxDiff = 500,
                    ColorResolution = 7,
                    Palette = ColorPaletteHelper.GetCloseImagePalette((RasterImage)image, 1 << 8),
                    LoopsCount = 1
                    /*new ApngOptions
            {
                CompressionLevel = 9,
                Progressive = true,
                ColorType = PngColorType.IndexedColor,
                Palette = ColorPaletteHelper.GetCloseImagePalette((RasterImage)image, 1 << 8)
            }*/
             /*new Aspose.Imaging.ImageOptions.TiffOptions(TiffExpectedFormat.Default)
            {
                Photometric = TiffPhotometrics.Ycbcr,
                Compression = TiffCompressions.Deflate,
                BitsPerSample = new ushort[] { 8, 8, 8 }
            }*/
                /*new GifOptions
                {
                    IsPaletteSorted = false,
                    DoPaletteCorrection = false,
                    MaxDiff = 500,
                    ColorResolution = 7,
                    Palette = ColorPaletteHelper.GetCloseImagePalette((RasterImage)image, 1 << 8),
                    LoopsCount = 1
                    
                }*/
                }
}

Also please note, that we obtained files smaller size than yours using compression options for different formats, including PSD compression RLE, the best that supported, produced size is 600Mb and there is not ability to decrease it more. All other formats presented in example produce files smaller than yours. You can export your file to next supported multipage formats: Tiff, Gif, Psd, Apng, Webp.
Related export to 1-paged formats like bmp you can export each page of your tiff file, like

using (TiffImage image = (TiffImage)Image.Load(@"c:\Users\USER\Downloads\Source.tif"))
            {
                int bits = 4;
                image.Pages[0].Save("1.bmp", new BmpOptions()
                {
                    Compression = Aspose.Imaging.FileFormats.Bmp.BitmapCompression.Rgb,
                    BitsPerPixel = bits,
                    Palette = ColorPaletteHelper.GetCloseImagePalette((RasterImage)image, 1 << bits)
                });

Please use documentation related to multipage export Working with multipage image formats|Documentation and compression of images Compress images Via net, all supported image formats | products.aspose.com also it maybe helpful for you to use our gist examples related to compression compress-apng.cs · GitHub and multipage images create-animation-from-array-of-images.cs · GitHub