ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 PDF image compression

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AScomp Posted - Feb 25 2022 : 19:13:49
Hi,

is there a way to compress images in a PDF file with ImageEN?

I would like to open a specific PDF file, reduce quality of images included in the PDF file and save the PDF (to reduce PDF file size).

Kind regards

Andreas
6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 23 2025 : 21:19:30
Hi

Actually with the new compression support we have added for PDFium in v14.0.1, this should now be possible without downgrading the content to images.

// Reduce the size of the PDF file by lowering the quality of the images and enabling JPEG compression (B is a TIEBitmap)
ImageEnView1.IOParams.PDF_Compression := ioPDF_JPEG;
ImageEnView1.IOParams.JPEG_Quality    := 75;
for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
begin
  oPDF := ImageEnView1.PdfViewer.Objects[i];
  if (oPDF.ObjectType = ptImage) then
  begin
    B := TIEBitmap.Create();
    try
      if oPDF.GetImage( B ) then
      begin
        B.Resample( 0.5 );
        oPDF.SetImage(B);
       end;
    finally
      B.Free;
    end;
  end;
end;
ImageEnView1.PdfViewer.ReloadPage();


https://www.imageen.com/help/TPdfObject.SetImage.html

Nigel
Xequte Software
www.imageen.com
mdgodfrey Posted - Apr 23 2025 : 16:46:24
Did you end up doing this? How did it work out?
yeohray2 Posted - Sep 14 2022 : 18:12:39
Hi Nigel,

Thanks, will try this.

Ray
xequte Posted - Sep 10 2022 : 00:27:08
Hi Ray

Specifically speaking, ImageEn can do this:

1. Load the pages of the PDF as images (using PDFium). Note that this includes the whole page, so you would need to crop them in some way, e.g. using:

https://www.imageen.com/help/TImageEnProc.AutoCrop.html


2. Resample the images to lower the resolution:

https://www.imageen.com/help/TImageEnProc.Resample.html


3. Save the set of images as a new PDF (ImageEn native PDF support):

https://www.imageen.com/help/TImageEnIO.CreatePDFFile.html


It is not an ideal solution. I expect there are better/easier ways to do this.



Nigel
Xequte Software
www.imageen.com
yeohray2 Posted - Sep 09 2022 : 20:18:35
I'm exploring this too - I have PDFs where users embed images with 300dpi resolution unnecessarily. Ideally, I would like to extract those images, reduce the resolution, then replace the original images with these resampled images. Is that possible using ImageEn?

Thanks in advance.

Ray
xequte Posted - Feb 26 2022 : 17:19:53
Hi Andreas

If the PDF only contains images, then yes (with caveats). If it contains text and other content that you don't want rasterized, then no.

Nigel
Xequte Software
www.imageen.com