Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, June 8, 2020 10:13:19 AM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


I'm splitting PDF to TIFF and the final TIFF files are having big file size for RasterImageFormat.Tif. Then I changed to RasterImageFormat.TifLzw the size reduced. Then again I tried with RasterImageFormat.CcittGroup4, the size still reduced but there were no colors. Please can you suggest on what format needs to be passed how to get best compressed size with colors?

Code:

using (var scodecs = new RasterCodecs())
{
    string multiPageFileName = $@"{currentPath}\Split Pdf\test.pdf"; //add file path here
    CodecsImageInfo info = scodecs.GetInformation(multiPageFileName, true);
    scodecs.Options.Load.SuperCompressed = true;
    //scodecs.Options.Tiff.Save.qua

    string outputDir = $@"{currentPath}\Split Pdf\"; //add output location here

    for (int pageNumber = 1; pageNumber <= info.TotalPages; pageNumber++)
    {
        // Load the next image in the loop 
        RasterImage simage = scodecs.Load(multiPageFileName, 0, CodecsLoadByteOrder.BgrOrGray, pageNumber, pageNumber);

        // Save the page to a separate file 
        string pageFileName = Path.Combine(outputDir, "Page_" + pageNumber + ".tif");
        //scodecs.Save(simage, pageFileName, RasterImageFormat.TifLzw, 0);
        //scodecs.Save(simage, pageFileName, RasterImageFormat.Ccitt, 0);
        scodecs.Save(simage, pageFileName, RasterImageFormat.CcittGroup4, 0);
        simage.Dispose();
    }
}
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, June 9, 2020 4:36:47 PM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 105

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

When converting to a raster image format such as TIFF you are going to get a larger file size than vector formats since there is typically a higher DPI and each software needs to be able to render each pixel. If you are splitting a PDF file to TIFF and you want to keep the the color of the original file and get the best compression size you will want to use JPEG411 compression on the TIFF file: RasterImageFormat.TifJpeg411.

CCITT compression is a 1-bit compression, so it'll have the best file size but your image will be black and white. If you want to have the best compression size with the best quality you will want to use: RasterImageFormat.TifJpeg.

If you want to look into converting each file to the best compression with the best quality for each image I would recommend using the DocumentConverter as it does all that automatically.

Let me know if you have any further questions on the above information.

Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.044 seconds.