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
 bad quality while converting
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lorife

Italy
44 Posts

Posted - Sep 01 2022 :  09:06:19  Show Profile  Reply
Hello,
I'm switching from another component to your and I'm having some problems with the quality of the image.
I am reading a TIF, splitting it, and then saving to PDF.
The PDF I receive is blurried compared to the other components and I would like to understand if I can change something.

In both cases I resize the image to 1280 and I change the colors to 256, no filters applied.

Just to test it, I also tried saving back to TIF instead than PDF to see what happens but still it's worse.

The most important parts of the code I use are these:

IEGlobalSettings().RegisterPlugIns([ iepiPDFium ]);
IEGlobalSettings().PdfViewerDefaults.DPI := 144;

iev_IN.Proc.Resample(1280,1000,0,1);
iev_IN.Proc.ConvertTo(256);

bmp := iev_IN.IEBitmap;
idx := iemv_OUT.AppendImage;
iemv_OUT.SetImage(idx, bmp);

iemv_OUT.MIO.Params[0].PDF_Compression  := TIOPDFCompression.ioPDF_JPEG;
iemv_OUT.MIO.Params[0].PDF_PaperSize    := TIOPDFPaperSize.iepA4;
iemv_OUT.MIO.Params[0].PDF_PaperLayout  := TIEPageLayout.ielPortrait;
iemv_OUT.MIO.Params[0].PDF_ImageOptions := [iepioShrinkOnly, iepioCentered];

iemv_OUT.MIO.Params[0].TIFF_Compression := TIOTIFFCompression.ioTIFF_JPEG;

iemv_OUT.MIO.DuplicateCompressionInfo();


then I save, in case of tif:

iemv_OUT.MIO.SaveToFile('c:\temp\a.tif', 0, true)


and in case of pdf:

iemv_OUT.MIO.SaveToFile('c:\temp\a.pdf', 0, true)


As there is some sensible data I'm sending you an email with the files.
Could you help me?

xequte

38610 Posts

Posted - Sep 01 2022 :  18:41:21  Show Profile  Reply
Hi

The main problem/difference is your resampling:

> iev_IN.Proc.Resample(1280,1000,0,1);

You have not specified a resample filter. This should be rfLanczos3 or something of similar quality:

http://www.imageen.com/help/TResampleFilter.html

Also, you have specified a maximum size of 1280x1000, but your other product's output is 1280 pixels high. If you are happy with 1280 in either dimension then use:

iev_IN.Proc.Resample( 1280, 1280, rfLanczos3, True );

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

That will give you the same output as your other image.


Other points:
- I'm not sure there is much value in reducing colors to 256 if you are using JPEG compression
- PDFium is not used when saving an image to PDF, native code is used for that




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

lorife

Italy
44 Posts

Posted - Sep 02 2022 :  03:13:43  Show Profile  Reply
Hello,
thank you for the answer.
I tried and it works, it's even better.

some more question:
1. it's true that i had set 1280x1000 but I had also set TRUE as the last parameter. Doesn't that take care of setting the correct size?
2. I might be wrong but the other components did not use any filter, is it possible that here I have to to achieve this result (which is better by the way)?
3. I tried without reducing colors and the file got 1Kb bigger, maybe it makes sense to use after all, on bigger files?
4. I did not use PDFium because it's not thread safe, also if I use that I cannot rotate the image when needed.
5. Is there a way to achieve a similar result with a faster filter? I have to process many tif and create many pdf
6. How is it possible that the other component creates a smaller file and (if nr.2 is true) without filters?
Go to Top of Page

xequte

38610 Posts

Posted - Sep 02 2022 :  23:26:16  Show Profile  Reply
Hi

1. If you specify Resample( 1280, 1000, rfLanczos3, True ) then you are saying the maximum height is 1000pixels, but you want the maximum height to be 1280


2. They have also used a filter/algorithm, otherwise there would be missing rows in the image


3. There is probably no harm in using color reduction to reduce file size with gray scale images


4. PDFium cannot be used here, because ImageEn does not use it for Image->PDF output


5. You can use rfFastLinear or a WIC filter. If you review the speed timings you will see they are very fast:

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


6. Are you getting a larger file size than before? Are the image sizes the same? PDF or TIFF? Please forward me new comparison images.



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