T O P I C R E V I E W |
jrpcguru |
Posted - Aug 29 2017 : 16:03:53 I am using ImageEn 7.0.1 with XE2 and recently installed the WPCubed MakeImagep plug in. First of all: a Big Thank You to Bill Miller for his demo program. It made it quite easy to install WPCubed and begin using it. But I have some questions:
1. If I scan a page at 200dpi, 24bit color, 8.5x11 page size and do this twice to make a two page file (ImageEnMView), I then save it as a multi-page PDF with 30% JPEG compression, it yields a file size of 55Kb. Before saving I display each page individually in an ImageEnView. ImageEnView1.DpiX reports only 72dpi. IntToStr(ImageEnView1.IEBitmap.Width) + ' x ' + IntToStr( ImageEnView1.IEBitmap.Height) reports 842x612. Neither of these seems correct for a 200dpi scan and the document size. Is there a more accurate method of measuring DPI and the dimensions of the image?
I am using the following settings for each page to save this PDF: ImageEnMView1.MIO.Params[i].JPEG_Quality := PDFCompression.Position; //Position = 30 ImageEnMView1.MIO.Params[i].PDF_Compression:=ioPDF_JPEG; ImageEnMView1.MIO.Params[i].PDF_PaperSize := iepAuto;
2. If I reload the PDF file into ImageEnMView and display an individual page in ImageEnView, it now reports 0 DPI and 3508x2550 pixels. In fact, some of my sample scanned files reload with over 70 megapixels when they were originally scanned at 200 dpi, and ImageEnMview does not like huge pages like that.
3. If I resave the PDF file, again using 30% compression, it yields a file size of 474kb When I reload the file it is now 6043x8313 pixels. 4. If I resave the PDF file again, the file size is now 3,988kb.
How can I reload PDF files with the same resolution as they were saved? How can I load any PDF file at a lower resolution to allow faster previewing, similar to: ImageEnView1.IO.Params.JPEG_Scale := ioJPEG_HALF; ImageEnView1.IO.Params.RAW_HalfSize := True;
J.R. |
14 L A T E S T R E P L I E S (Newest First) |
xequte |
Posted - Sep 10 2017 : 19:39:08 Hi JR
If you are using the WPViewPDF plug-in, the FileFormat will be iomscWPPDF, not ioPDF.
I've improved the documentation.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
jrpcguru |
Posted - Sep 08 2017 : 13:30:27 I wonder if I have found a bug:
else if (FindFileFormat(ImageFileName) = ioPDF) or (UpperCase(ExtractFileExt(ImageFileName)) = '.PDF') then begin try begin showmessage('loading PDF'); if FindFileFormat(ImageFileName, ffContentOnly ) = ioPDF then showmessage('PDF file recognized'); if FindFileFormat(ImageFileName, ffVerifyByExtension ) = ioPDF then showmessage('PDF file recognized by extension');
The 'loading PDF' message displays, but the other messages do not. FindFileFormat(ImageFileName) also does not work. I had to add the test for the file extension because FindFileFormat apparently isn't working. ImageFileName is a fully qualified file name.
Thanks for the info. I agree that there will be some degradation. That is why my scanning program discourages editing JPG files, preferring instead to inject changed data into the IPTC fields that I use. But I do allow it, since a one time image fix is probably more productive than re-scanning. So, you have given me hope that I can make a similar concept work for PDF files.
J.R. |
xequte |
Posted - Sep 08 2017 : 00:31:18 Hi JR
For all image formats that support it, DPI is set when reading the image (and not used for the loading). If you change it, it should be to something valid, not 0 (because it will be saved if the format supports it).
I understand your suggestion regarding, injecting PDF info, but my quick review does not make it look practical without giving ImageEn the ability to load and parse the structure of PDF files. If you do find some code that can do this in a simpler way, please let me know.
Our PDF meta data block should have been consistent between most versions (i.e. has changed little since its first implementation).
> if ImageEn is writing a simple image and I can save metadata to identify the > PDF as created by ImageEn and can save the height/width and/or DPI, then I > should be able to read the image, edit it, and resave it, shouldn't I?
Yes, but the image will undoubtedly degrade a little with each saving. Firstly you are using a lossy compression (ioPDF_JPEG) and secondly, ImageEn is adding an image to a page, wpViewPDF is rendering that page to an image, which you save as an image on a page. Undoubtedly there will be something lost in that transaction.
IOW, it will work, but it is not recommended. For the same reason, I also do not recommend JPEG for images that need to be resaved.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
jrpcguru |
Posted - Sep 07 2017 : 22:35:32 If Hurricane Irma doesn't mess me up, I will be traveling and unable to work on this for at least a week. But I've come up with some more questions:
ImageEnView1.IO.Params.DPI := 200; works for reloading PDF files. Am I correct that setting .DPI = 0 is the correct way to cancel a setting? Am I also correct that this value only affects PDF files, so I can safely use it without affecting .JPG or .TIF? (I have a quality setting option that uses something like this for the half quality option: ImageEnView1.IO.Params.JPEG_Scale := ioJPEG_HALF; ImageEnView1.IO.Params.RAW_HalfSize := True; ImageEnView1.IO.Params.DPI := 200;
You declined my suggestion about injecting PDF metadata. I've just realized that injecting may have a specific meaning to you. I think with EXIF and IPTC you are directly overwriting the previous values in the file. With PDF metadata, as best as I can figure, each time a program edits the metadata, it writes an entirely new block of metadata at the end of the file. (I have a sample with approx. 10 metadata blocks!) So I wonder if ImageEn could have a feature that just rewrites the metadata without changing anything else? I will also look into whether I can figure out how to do that, but I'm sure your solution would be more elegant. If so, then resaving the entire file, including the image, would not be needed in most cases.
While researching the metadata and how to read it, I've found quite a lot of variation in the opening tags and closing tags that are used by different software. Has ImageEn been consistent over the years in the structure of its PDF metadata tags? If so, I might just write a metadata reading function that only reads that structure. I have no desire to edit PDF metadata created by other software, but do want to be able to edit PDF files created by my programs.
You have said that PDF files are very complex and should not be considered an image format. I can understand that now. But if ImageEn is writing a simple image and I can save metadata to identify the PDF as created by ImageEn and can save the height/width and/or DPI, then I should be able to read the image, edit it, and resave it, shouldn't I?
J.R. |
xequte |
Posted - Sep 06 2017 : 22:48:29 Hi JR
You can email me for a pre-release.
PDF_PaperWidth is in PDF Points, i..e 72 to an inch so:
widthInInches := PDF_PaperWidth / 72;
displaySizeInPixels := widthInInches * DpiX;
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
jrpcguru |
Posted - Sep 06 2017 : 22:20:51 That sounds excellent. Thank you! Any idea when the next version will arrive? I've just discovered that you can't set the Params.DPI in ImageEnMView until it is loaded, so I had to loop through the pages with ImageEnView and transfer each page to ImageEnMView. Hopefully your new approach will beat that!
Is there a way to convert ImageEnView.Width to PDF_PaperWidth?
J.R. |
xequte |
Posted - Sep 06 2017 : 21:59:35 Hi
FYI, the next version of ImageEn will allow you to specify the size to load PDF files.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
xequte |
Posted - Sep 05 2017 : 23:00:49 Hi JR
I just had a quick look at the code, and it would not be easy for us to do an inject type method unless we actually supported native loading.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
jrpcguru |
Posted - Sep 05 2017 : 08:50:49 When I think about it, making a scanning error with the images, for example, a wrong rotation like I suggested before, is probably fairly unlikely. But it is really easy to make data errors with the genealogical data of Title, Location, Source, Date, and Description. I currently store that in the standard PDF metadata fields, including PDF_Keywords which is where I put the description. Since the matching IPTC field only allows 2,000 characters, I limit PDF_Keywords to 2,000 also, though I suspect that isn't needed. So I think you can guess what my next idea is: You currently provide for injecting EXIF and IPTC into JPG and TIF files. Could you add a PDF metadata injection feature? That would allow correcting the stored metadata without worrying about accurately reloading/resaving the image for each page.
J.R. |
xequte |
Posted - Sep 04 2017 : 22:25:59 Hi JR
It's always difficult with a library like this to decide how you define the range of functionality you support, ImageEn is an "image library", so how much should we support video files, for example, or document formats like PDF? If we support PDF, do we also need to support Word or PowerPoint???
The answer is that it is mostly customer driven. If enough users tell us that they need a feature, and it is not too far out of our scope then we look into it.
PDF is one of those, particulary with regard to scanning, users often want to output to PDF. Of course, creating a PDF compatible file is infinitely easier than loading every PDF file out there, so loading needs to be supported by a third party. But as mentioned earlier, PDF is not an image format, so if you plan on saving, loading and then re-saving images, you should really be using an image format.
If you want your PDF files to store the used DPI, you might use one of the PDF meta-data fields, such as Keywords:
https://www.imageen.com/help/TIOParams.PDF_Keywords.html
Nigel Xequte Software www.xequte.com nigel@xequte.com |
jrpcguru |
Posted - Sep 04 2017 : 15:52:53 Thank you for the prompt reply. I understand the situation considerably better now. I have spent a bunch of time trying to read the PDF parameters with my own code and hope to include that in another topic that I started about parameters, perhaps later this week. I have been fairly successful but did not think to try to find PaperWidth and PaperHeight. It seems like proper reloading of an ImageEn produced PDF might require reading that first if I want to get ahead of Julian - probably not a good idea since he is surely the expert. But I wonder if ImageEn could automatically create a custom ID parameter that recorded the DPI so it could be read before setting ImageEnView1.IO.Params.DPI and then reloading the file? I also wonder if ImageEn creates a much simpler PDF file, perhaps it needs a custom parameter that WPViewPDF can detect and render the image in a simpler method?
I wouldn't be surprised if you are regretting adding PDF viewing to ImageEn. I hope to get the wrinkles ironed out since it would be pretty handy for my work.
J.R. |
xequte |
Posted - Sep 03 2017 : 18:31:40 Hi JR
What paper size is being used here:
ImageEnMView1.MIO.Params[i].PDF_PaperSize := IECalcPaperSize( ImageEnMView1.MIO.Params[ i ].Width, ImageEnMView1.MIO.Params[ i ].Height, False );
Presumably it is something non-standard. I expect when you examine the PDF files created in Primo and ImageEn they will have different page sizes and image quality.
PDF can really only be considered an image storage format, in the same way as a Word document can store images.
If you discover an image needs rotation or editing of meta-data, that does not require re-scanning, just for the image to be rotated and/or edited.
With regard to your questions:
1. PDF file does not have "DPI", it has page sizes. When saving in ImageEn, it creates the image at your specified page size, scaling the image to display within the pages. Likewise, when reading, there is no PDF information for the WPViewPDF plug-in to read, so it takes the DPI you have specified for the display imageenview/bitmap to scale the result.
For example, if you have set ImageEnView1.IO.Params.DPI := 200; then loading a US Letter size (8.5x11") PDF file will generate an image of 8.5x200 x 11x200 = 1,700 x 2,200 pixels.
Saving PDF in ImageEn and loading via WPViewPDF should not be considered as 1:1. As a document format, PDF may contain text and other objects, so WPViewPDF "renders" it as a raster image, which is a much more sophisticated process than ImageEn PDF saving which only creates a PDF page and outputs an image to it.
2. Set a lower DPI before loading, i.e. ImageEnView1.IO.Params.DPI := ...;
3. No, as mentioned DPI is not supported by PDF, but I will make a request to Julian that they fill the PDF parameters, such as PaperWidth and PaperHeight
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
jrpcguru |
Posted - Sep 02 2017 : 20:34:23 I found the cause of ImageEn converting my request for 200dpi scanning to 72dpi. I had accidentally set ImageEnMView1.MIO.TwainParams.CompatibilityMode = true
So now requesting a 200dpi scan yields a 200dpi scan. But if I scan an 8.5x11 page at 200dpi, it yields about an 8megapixel file, but when I reload with MakeImage, it becomes 64mp! And it loads grossly slowly.
As I see it, there are 3 possible causes for this: 1. I am doing something wrong in saving the images as a .PDF file. I use the following code for a multi-page PDF file:
11: //multi page .PDF, variable compression
begin
try
for i:=0 to ImageEnMView1.ImageCount-1 do begin
if ImageEnMView1.ImageBitCount[i]=1 then
begin
ImageEnMView1.MIO.Params[i].PDF_Compression:=ioPDF_LZW;
end
else
begin
ImageEnMView1.MIO.Params[i].JPEG_Quality := PDFCompression.Position; //1 to 100
ImageEnMView1.MIO.Params[i].PDF_Compression:=ioPDF_JPEG;
end;
ImageEnMView1.SelectedImage := i;
//from forum: https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=2026&SearchTerms=PDF_Papersize,PDF_Paperwidth
// ImageEnMView1.MIO.Params[ i ].PDF_PaperWidth := ImageEnMView1.MIO.Params[ i ].Width;
// ImageEnMView1.MIO.Params[ i ].PDF_PaperHeight := ImageEnMView1.MIO.Params[ i ].Height ;
// ImageEnMView1.MIO.Params[i].PDF_PaperSize := iepAuto;
ImageEnMView1.MIO.Params[i].PDF_PaperSize := IECalcPaperSize( ImageEnMView1.MIO.Params[ i ].Width, ImageEnMView1.MIO.Params[ i ].Height, False );
end;
finally
sFileExt := '.PDF';
// showmessage('set size of pages');
end;
All of the options that are commented out have been tried and yielded the same result.
2. ImageEn does something wrong in saving PDF files. Possible evidence: MakeImage has no trouble reloading PDF files created by many other programs. For example: using PrimoPDF printer driver to print an 8.5x11 document and MakeImage reloads it as a 300dpi file of an appropriate megapixels. And it loads quickly. So far, from all of my testing, only PDF files created by ImagEn fail to reload correctly.
3. MakeImage is doing something wrong. Since it loads PDFs from all other sources correctly, this seems unlikely.
I disagree that PDF should not be considered an image format. I see no reason to purchase the MakeImage plugin if it can not reload a PDF file. For example: my scanning program is designed particularly to help with genealogy documents. It saves Title, Description, Location, Source, and Date data fields into IPTC data for JPG and TIF and into PDF metadata. It would be quite normal to discover an error in that data or perhaps a page that needed to be rotated, many months after the genealogy documents had been stored away. Of course I would want to load the PDF and fix it, not rescan the documents which may not be easily accessed!
With the current situation, PDF files created by other PDF programs are loaded quickly and displayed. Those created by ImageEn are grossly slow in loading or generate errors because they are so big. I've had a few that ballooned out to 120 megapixels!
So we have outstanding questions: 1. How can I reload PDF files generated by ImageEn with the same resolution as they were saved? 2. Is there a way to load any PDF file at a lower resolution to allow faster previewing, similar to: ImageEnView1.IO.Params.JPEG_Scale := ioJPEG_HALF; ImageEnView1.IO.Params.RAW_HalfSize := True; 3. Is there any way to obtain the DPI when loading a PDF file? ImageEnView1.DpiX currently reports 0 for any PDF file.
In another topic you suggested that I ask Julian on the WPCubed forum. I hope to do so, but it is almost a week since requesting access to their forum and I haven not received permission yet. In the meantime, I think it is important than ImageEn customers thinking of purchasing the plugin should be able to research issues on your forum.
J.R. |
xequte |
Posted - Aug 30 2017 : 19:38:59 Hi JR
842x642 for a 8.5x11 scan is a DPI of around 76. Are you able to reproduce that issue with our acquire demos? If you use the same settings in other scanner software, do you get a 200dpi image? Are you scanning with Twain or WIA?
You should not use PDF as an "image" format. PDF saving is handled internally, but loading is handled via a plug-in, so the results are not guaranteed to be the same (unlike loading a PNG, and then saving as PNG for example). It is best to think of PDF saving as an "Export" and pdf loading as an "Import".
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|