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 : Sunday, March 26, 2017 8:43:13 AM(UTC)
wangbill18

Groups: Registered
Posts: 45


Hi I am posting this again since my last post was deleted by someone. I will call in to report the deleted post incident.

After below code execution, rasterimage has resolution of 300 instead of 200.. Please help.. This is with latest V19 download.

Dim ms As New MemoryStream(m_document.Data)
_codecs.Options.Pdf.Load.DisplayDepth = 1
_codecs.Options.Load.AllPages = True
_codecs.Options.RasterizeDocument.Load.XResolution = 200
_codecs.Options.RasterizeDocument.Load.YResolution = 200
Dim rasImage As RasterImage
rasImage = _codecs.Load(ms)

Edited by moderator Monday, April 10, 2017 7:54:00 AM(UTC)  | Reason: Not specified

 

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 : Monday, March 27, 2017 8:37:12 AM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 171

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

Hello,

I apologize for the misunderstanding. An agent had posted on your previous post with the following:

Quote:
Hello,

By going off the code that you have provided, that should load your PDF at a 200 resolution. We have tested with your code on our end and cannot reproduce the issue so in order to proceed further I will send an email from support@leadtools.com to the email address that you registered on the forum to get further information from you. If that email address is not correct, please update it and let me know so I can resend the email.


The agent then sent you the following email to the address that you have registered on the forums:

Quote:
As mentioned in the forum post reply, I am contacting you to get further information regarding your forum post

Since we were unable to reproduce the issue mentioned, we will need a small sample application from you that shows your PDF loading with the incorrect resolution. Once we have this from you, our team can look further into your code to see what is causing this. You can reply back to this email with the two files that we will need from you to proceed further. Thank you for your cooperation


If you do not want to continue working on this issue over email and would prefer the forums, then please reply to my post with the following information:
  • Sample file this is happening with
  • More code showing what m_document is and where m_document.Data is being set or a small sample application


Please keep in mind when posting attachments that this is a public forum and anyone can see what you post, so please refrain from posting license files or sensitive information.

Edited by user Wednesday, April 19, 2017 1:30:46 PM(UTC)  | Reason: Not specified

Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 
#3 Posted : Tuesday, March 28, 2017 11:59:21 AM(UTC)
wangbill18

Groups: Registered
Posts: 45


Thanks for replying back and assistance, I will provide a sample app later. There is problem with the old post. When I clicked it, https://www.leadtools.co...is-not-working#post42592, I get Access Denied error.. That explains why I can't find the post. Was it hidden because I complained about no response?
 
#4 Posted : Tuesday, March 28, 2017 1:26:10 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 171

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

No, it was moved from the forums because the agent was transitioning it to an email case instead of public forums so that you could email in your sample application.
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 
#5 Posted : Tuesday, March 28, 2017 11:10:34 PM(UTC)
wangbill18

Groups: Registered
Posts: 45


I didn't get any email for some reason. I looked junk folder. Anyway, I tried code that simply loads from a tiff file, still has the same issue, like below code. What two files do you need from me?

Dim _codecs As New Leadtools.Codecs.RasterCodecs
_codecs.Options.Pdf.Load.DisplayDepth = 1
_codecs.Options.Load.AllPages = True
_codecs.Options.RasterizeDocument.Load.XResolution = 100
_codecs.Options.RasterizeDocument.Load.YResolution = 100
Dim rasImage As Leadtools.RasterImage
rasImage = _codecs.Load("C:\imaging\DEED114\00500\00105.tif")
 
#6 Posted : Thursday, March 30, 2017 1:51:42 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 171

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

Thank you for the information.

What is your goal with this code? The RasterizeDocument Load options are meant for use when loading Documents as images as described here:

Quote:
LEADTOOLS provides support for loading a document as a raster image. Document formats such as PDF, XPS, DOCX/DOC, PPTX/PPT, XLSS/XLS, RTF and Text do not contain physical width, height or resolution information. It is up to the loader (in this case, the RasterCodecs object) to specify the transformation from logical coordinates to physical pixels through a process called rasterization.
Rasterization is the process through which a document is converted into a raster image. To check whether a certain file on disk (or in a .NET stream) contains a document file rather than a regular raster image, call the RasterCodecs.GetInformationRasterCodecs.GetInformationAsync method and check the CodecsDocumentImageInfo.IsDocumentFile property. Here is a code snippet:


TIFF files have the DPI already embedded in the header information so when loading the image, the RasterCodecs class already knows what the DPI will be and it is already set. What is your goal in trying to force it to load at a certain DPI?
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 
#7 Posted : Sunday, April 2, 2017 11:19:32 AM(UTC)
wangbill18

Groups: Registered
Posts: 45


Ah. I see. I just realized the image bytes are actually Tiff instead of PDF it used to be, that is where the main confusion originated from. Is it possible to load Tiff in at a different DPI? Thanks!
 
#8 Posted : Monday, April 3, 2017 12:57:18 PM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 171

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

Can you elaborate on what exactly you are trying to accomplish by attempting to modify the DPI of the TIFF on load? TIFFs are already rasterized, meaning they already have Pixels and image data as well as header information that contains what the expected DPI is. Changing the DPI isn't going to accomplish anything since the data already exists. One thing you can do in order to modify the DPI + the actual Pixel data contained in the image is resize the image to a new width / height which will upscale or downscale the image based on what you want the DPI to be. For example, if you have a 100x100DPI TIFF and you are trying to get it ready for OCR and you want the best accuracy so you want to load it as 300 DPI, you can use the following method which will resize the image to 300x300:

Code:
      static void ResizeDPI(RasterImage image, int xResolution, int yResolution)
      {
         if (image.XResolution == xResolution && image.YResolution == yResolution)
            return;

         double width = (image.Width / image.XResolution) * xResolution;
         double height = (image.Height / image.YResolution) * yResolution;
         SizeCommand sizeCommand = new SizeCommand((int)width, (int)height, RasterSizeFlags.Bicubic);
         sizeCommand.Run(image);
         image.XResolution = xResolution;
         image.YResolution = yResolution;
      }


If your TIFF for some reason does not have any header information about what the DPI should be, then you can specify in the Codecs load options what you want to default the DPI to by using the following 2 lines of code prior to loading your image:

Code:
         codecs.Options.Load.XResolution = 300;
         codecs.Options.Load.YResolution = 300;


If this doesn't answer your question, please let me know!

Thanks,
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 
#9 Posted : Tuesday, April 4, 2017 7:38:26 AM(UTC)
wangbill18

Groups: Registered
Posts: 45


My Tiff file comes in as 300 DPI, I have to save it in 2000 DPI. For the resize code, I noticed it can only do one page a time. For multi-page tiff, I have to resize page by page. Is there a way to resize all pages once?
 
#10 Posted : Thursday, April 6, 2017 8:32:43 AM(UTC)

Hadi  
Hadi

Groups: Manager, Tech Support, Administrators
Posts: 171

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

Unfortunately, the only way would be to loop over each page and call sizeCommand.Run(image) for each page like so:

Code:
      static void ResizeDPI(RasterImage image, int xResolution, int yResolution, bool allPages)
      {
         if (image.XResolution == xResolution && image.YResolution == yResolution)
            return;

         double width = (image.Width / image.XResolution) * xResolution;
         double height = (image.Height / image.YResolution) * yResolution;
         SizeCommand sizeCommand = new SizeCommand((int)width, (int)height, RasterSizeFlags.Bicubic);

         if (allPages)
         {
            for (int page = 1; page <= image.PageCount; page++)
            {
               image.Page = page;
               sizeCommand.Run(image);
               image.XResolution = xResolution;
               image.YResolution = yResolution;
            }
         }
         else
         {
            sizeCommand.Run(image);
            image.XResolution = xResolution;
            image.YResolution = yResolution;
         }
      }
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.

LEAD Logo
 
#11 Posted : Thursday, April 6, 2017 9:38:03 PM(UTC)
wangbill18

Groups: Registered
Posts: 45


thanks. you can edit PDF out of the subject since that is not true.
 
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-2017, Yet Another Forum.NET
This page was generated in 0.404 seconds.