Cannot compress PDF using defined JPEG2000 quality factors

Discussions about PDF management.
Post Reply
fs051268
Posts: 25
Joined: Wed May 22, 2013 4:00 pm

Cannot compress PDF using defined JPEG2000 quality factors

Post by fs051268 » Thu Mar 24, 2016 9:45 pm

Hi,

I tested the compression of gray scale and color images in a pdf but I don't quite understand how to compress using JPEG2000 compression using different quality factors.

Code: Select all

 GdPictureImaging tiffImg = new GdPictureImaging();
      //Load tiff
      int ImageId = tiffImg.CreateGdPictureImageFromFile(filePath);
      //Create new pdf
      GdPicturePDF pdfImg = new GdPicturePDF();
      pdfImg.EnableCompression(true);
      pdfImg.NewPDF();
      //Set compression ratios
      pdfImg.SetJpeg2000Quality(500);
      pdfImg.SetJpegQuality(100);
      //Add image to page
      GdPictureStatus status = pdfImg.AddImageFromGdPictureImage(ImageId,  PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone);
      status = pdfImg.SaveToFile(destFile, true, false);
No matter what value I set for SetJpeg2000Quality, the size of the file seems to only be affected by the value for SetJpegQuality. How can I catually use the JPEG2000 compression?

Attached my console app that I did for testing.
How can I compress using different JPEG2000 quality factors?

Thanks for your help!
Attachments
CompressionTest.zip
console app to test
(627.21 KiB) Downloaded 272 times
color.zip
color tiff image
(1.79 MiB) Downloaded 293 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Cannot compress PDF using defined JPEG2000 quality facto

Post by Loïc » Fri Mar 25, 2016 3:02 pm

Hello Ferdinand,

The GdPictureImaging class do not offer a way to change the JPEG 2000 quality factor used by the . If you want to do that you have to use the GdPicturePDF class.

Also you are using a method dedicated for multipage tiff documents (PdfCreateFromMultipageTIFF()) on a single page tiff document.


So basically I don't know what you are trying do do or demonstrate, but if your goal is to produce PDF document by controlling any aspect of the compression you definitively need to use the GdPicturePDF class.

Please let me know if you need further information.

With best regards,

Loïc

fs051268
Posts: 25
Joined: Wed May 22, 2013 4:00 pm

Re: Cannot compress PDF using defined JPEG2000 quality facto

Post by fs051268 » Fri Mar 25, 2016 3:09 pm

Hi,

I don't understand - I am using the GdPicturePDF to generate a new PDF and adding pages from a tiff image to it.

I am not using the PdfCreateFromMultipageTIFF - where do you see that?


This was my code ( as pasted in my initial post);

Code: Select all

GdPicturePDF pdfImg = new GdPicturePDF();
      pdfImg.EnableCompression(true);
      pdfImg.NewPDF();
      //Set compression ratios
      pdfImg.SetJpeg2000Quality(500);
      pdfImg.SetJpegQuality(100);
      //Add image to page
      GdPictureStatus status = pdfImg.AddImageFromGdPictureImage.....
Last edited by fs051268 on Fri Mar 25, 2016 3:12 pm, edited 1 time in total.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Cannot compress PDF using defined JPEG2000 quality facto

Post by Loïc » Fri Mar 25, 2016 3:11 pm

This is not what your attached application is doing. Could you provide a complete code snippet so I will be able to explain where the error is?

fs051268
Posts: 25
Joined: Wed May 22, 2013 4:00 pm

Re: Cannot compress PDF using defined JPEG2000 quality facto

Post by fs051268 » Fri Mar 25, 2016 3:37 pm

Hi,

here a test console app that I am using. It generates file names based on the quality factor for JPEG and JPEG2000.
To me, it looks as if the JPEG2000 factor does not take effect but only the JPEG factor:
Screen Shot 2016-03-25 at 14.31.59.png
Generated Files
Screen Shot 2016-03-25 at 14.31.59.png (14.05 KiB) Viewed 5475 times
Thanks for your help!
Attachments
JpegCompressionIssue.zip
Console App
(1.87 MiB) Downloaded 277 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Cannot compress PDF using defined JPEG2000 quality facto

Post by Loïc » Fri Mar 25, 2016 3:49 pm

This is normal, you are creating PDF with JPEG compression. If you want to use jpeg 2000 compression you need to specify that by using the SetCompressionForColorImage().

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest