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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Save to PDF and file size
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Dany

67 Posts

Posted - Jul 16 2018 :  15:43:35  Show Profile  Reply
Hello!

I am running this procedure before I to save to PDF and TIFF (to ensure the target to be not to big):

procedure TImgCollection.ResampleAll;
var
  i: integer;
begin
  for i := 0 to MView.ImageCount-1 do
  begin
    MView.MIO.Params[i].TIFF_Compression := ioTIFF_JPEG;
    MView.MIO.Params[i].PDF_Compression := ioPDF_LZW;
  end;
  MView.IEMBitmap.ResampleAll(900, 900, rfLanczos3, True, True); 
end;


The case is:

- I start a new component sessión, then I aquire from scanner a few images, and then I save to PDF.
- Then I save the same content to a TIFF.
- Then I do MView.Clear;
- Then I load the saved TIFF.
- Then I save to a new PDF.

Always the last saved PDF is 30% bigger than the first one.

Is there something I am missing?

Thank you!

xequte

39053 Posts

Posted - Jul 16 2018 :  20:13:39  Show Profile  Reply
Hi Dany

In both cases of saving the PDF did you call your ResampleAll method?

Are you able to reproduce the issue by loading a TIFF instead of acquiring? If so, please email me the TIFF.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Dany

67 Posts

Posted - Jul 17 2018 :  08:08:40  Show Profile  Reply
Hi Nigel;

Yes! I always do ResampleAll before. I am sending you the example files by email.
Go to Top of Page

xequte

39053 Posts

Posted - Jul 17 2018 :  23:24:46  Show Profile  Reply
Yes, the PDF files do get unexpectedly larger with subsequent saves using ioPDF_LZW. We'll investigate that.

Changing the compression types also resolves the issue. As your images are monochrome, ioTIFF_JPEG would not generally be used (because it is lossy and blurs the document). TIFF has specific compression algorithms for monochrome images.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Dany

67 Posts

Posted - Jul 18 2018 :  08:21:54  Show Profile  Reply
Hi Nigel;

I found that, if I use:

ImgNavigate.MIO.Params[i].TIFF_Compression := ioTIFF_LZW;
ImgNavigate.MIO.Params[i].PDF_Compression := ioPDF_LZW;

Then the problem does not exist anymore. But ioTIFF_LZW is doing a little bigger TIFF than ioTIFF_JPEG.
Go to Top of Page

xequte

39053 Posts

Posted - Jul 19 2018 :  01:56:14  Show Profile  Reply
Yes, but is lossless (nice crisp documents). JPEG compression is really only good for photos.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

39053 Posts

Posted - Jul 23 2018 :  18:58:13  Show Profile  Reply
Here's a better explanation from my partner:

JPEG compression never produces the same image of source, because it is lossy compression.
Loading and saving in sequence N times, produces N different images. LZW produces different sizes because it compresses different images.
out1.tiff, out2.tiff, out3.... aren't the same image (try to compare them pixel by pixel).
The size increases due the artefacts introduced by jpeg compression: anyway the increment stops after a number of savings.
To avoid this effect it is necessary to avoid ioTIFF_JPEG saving the TIFFs, and use a lossless compression, for example ioTIFF_lZW even for the TIFF.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: