i2pdf - image to pdf

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

i2pdf - image to pdf

Post by luis »

http://luis.no-ip.net/i2pdf/i2pdf.zip

This a little tool I wrote for myself, but maybe someone else can find it useful so I decided to release it as freeware.

I'm using it to convert instruction manuals, invoices, etc. after I acquired them with a scanner to a PDF.
Previously I was using other programs but as I wrote in the help I wasn't quite happy with them.

So I wrote this one.

Ciao!
Last edited by luis on Thu Dec 28, 2023 4:44 pm, edited 3 times in total.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2810
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Nice! I like it :D
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Num3 wrote:Nice! I like it :D
Thank you! It does its job :)
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Very nice luis. Thanks for sharing 8)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Good job! Thanks for sharing, this is a useful little utility.
BERESHEIT
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Thank you guys, I'm happy someone else can find it useful!
User avatar
idle
Always Here
Always Here
Posts: 5097
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

This will come in very handy, thanks.
User avatar
OldSkoolGamer
Enthusiast
Enthusiast
Posts: 150
Joined: Mon Dec 15, 2008 11:15 pm
Location: Nashville, TN
Contact:

Post by OldSkoolGamer »

This is cool, I like it, will come in handy. Thanks :D
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Updated to 1.0.15, fixed some bugs and added a statusbar.

Probably last release unless further bug fixing needed.

Now on with the next little silly project.

Bye!
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Post by Vera »

Hi luis,

Thanks for sharing your handy util :)

I'd like to point out two things:
- starting your app and dropping images onto it, the previous selection vanishes immediately because of the presetting to do so. This is quite irritating as one doesn't know about it at that time.

- I wasn't able to include the original file-sizes, no matter what settings I tried out. Though the log confirmes 'Resizing = 100 %' all images are enlarged to over 200 %.
Is it on purpose when using small pictures or which setting should definitively lead to 1:1 including so I can try it again ?

Greeting ~ Vera

p.s.: and what does Speed : Too fast for me. mean ?
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Hi Vera
Vera wrote: - starting your app and dropping images onto it, the previous selection vanishes immediately because of the presetting to do so. This is quite irritating as one doesn't know about it at that time.


You are not the first person telling me this.
It's the default because it follow the type of use I designed the app around (my typical way to use it, I mean).
It's however selectable in the options and it's well explained in the manual.

ANYWAY, I'll probably change the default value since it seem to create confusion in many people. :shock:

Vera wrote: - I wasn't able to include the original file-sizes, no matter what settings I tried out. Though the log confirmes 'Resizing = 100 %' all images are enlarged to over 200 %.


Resized means the original imaged is scaled down to a lower resolutions and stored in the pdf at that resolution.
If you selected 100% the images are not resized and are stored in the PDF at their native resolution.
So they cannot possibly be enlarged (unless you found a bug but at the moment I don't think so).

BUT even if stored as unchanged inside the PDF (100%) the way you'll see it on the screen depends on the viewer settings.
It's all explained in the manual in the "PDF Creation" section (there is an example with a flower).
Anyway, in your case:

1) if you have selected "paperless" as paper format, if the image is smaller than the desktop resolution and you want to keep it small when visualized, you can select "true size" in "startup mode".
If you use "fit to page" for example, the viewer will stretch the image to fill the available screen space.

2) if you have selected any other paper format, you probably want again "true size" but with "Enlarge to fit page if smaller" option disabled.

The same way, if you store in a PDF an image much larger than the screen and then use "true size" instead of "fit page" (for example) you will see only a portion of the image and you'll need to scroll to see it all.

Hope this helps.
Vera wrote: p.s.: and what does Speed : Too fast for me. mean ?


This is printed in the log instead of the processing speed expressed in MB/sec when the total processing time is less than a second.
It's a little joke, instead of writing something like "the total time elapsed and the total data processed are too small to print a value of some significance."
This happen if you for example drop a single, small file to convert it to a single page's PDF, probably to try the program ...
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Post by Vera »

Hi luis,

thanks for the explicitly reply. Your first commendation is what I had chosen from the second try on and afterwards I cross-tested other settings. Doing it all again was not successful to gain a pdf showing the original sized image.

here's one log as example:
=======================
i2pdf 1.0.15 (x86)
Image compression = PNG (lossless)
Resizing = 100 %
Paper format = Paperless
Startup mode = True size
[OK] Page 1: D:\PureBasic\fo-ENGL\Nova\nova_07a.png (243,8 %)
[OK] Page 2: D:\PureBasic\fo-ENGL\Nova\nova_05.png (201,9 %)
[OK] Page 3: D:\PureBasic\fo-ENGL\Nova\nova_03.png (204,3 %)
[OK] Page 4: D:\PureBasic\fo-ENGL\Nova\nova_05a.png (271,9 %)
[OK] Page 5: D:\PureBasic\fo-ENGL\Nova\nova_07.png (202,2 %)
Start time : 20.08.09 17:07:02
End time : 20.08.09 17:07:02
Elapsed time : Less than a second.
Output file : C:\Dokumente und Einstellungen\user\Desktop\testIP3.pdf (63.179 bytes)
Enlarged to : 221,1 %
Speed : Too fast for me.
Files processed : 5 (28.576 bytes)
Files skipped : 0
Files missing : 0
NO ERRORS
===========================


But I found something curious: opening the PDF (useing obove settings) I'll see the pictures double-sized while the pdf-zoom is expectant on 100%. Now, if I change this pdf-zoom to 50% I really get 50% sight of the images - but turning it back to 100% the images are again displayed double-sized (~ 200%).

ps.: 'cos I did read your manual - especially intens after not gaining what I aimed at :wink:

And sorry, I forgot to tell you that it doesn't make any difference if all /some or none of the files are marked, always all of them will be processed.


Greeting ~ Vera

Speed : Too fast for me.
It's a little joke

great - I was only unsure 'bout it :lol:
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Vera wrote:Doing it all again was not successful to gain a pdf showing the original sized image.
Sorry but I'm not sure to understand what you are saying.

If possible do the following:

1) post a test image somewhere where I could get it
2) post the result pdf (from that image) exibiting the problem (because I simply don't understand)
Vera wrote: here's one log as example:
=======================
i2pdf 1.0.15 (x86)
Image compression = PNG (lossless)
Resizing = 100 %
Paper format = Paperless
Startup mode = True size
[OK] Page 1: D:\PureBasic\fo-ENGL\Nova\nova_07a.png (243,8 %)
[OK] Page 2: D:\PureBasic\fo-ENGL\Nova\nova_05.png (201,9 %)
[OK] Page 3: D:\PureBasic\fo-ENGL\Nova\nova_03.png (204,3 %)
[OK] Page 4: D:\PureBasic\fo-ENGL\Nova\nova_05a.png (271,9 %)
[OK] Page 5: D:\PureBasic\fo-ENGL\Nova\nova_07.png (202,2 %)
Start time : 20.08.09 17:07:02
End time : 20.08.09 17:07:02
Elapsed time : Less than a second.
Output file : C:\Dokumente und Einstellungen\user\Desktop\testIP3.pdf (63.179 bytes)
Enlarged to : 221,1 %
Speed : Too fast for me.
Files processed : 5 (28.576 bytes)
Files skipped : 0
Files missing : 0
NO ERRORS
===========================
Are you talking about "(243,8 %)" and the others percentage ?
They are referred not the SIZE OF THE IMAGE (width x heigth) but the SIZE OF THE FILE (bytes).
You are saving as lossless PNG, so it's not so uncommon to have a file larger than the source. It depends from the source, obviously.
i2pdf help wrote: A line for every file processed, starting with [OK] is successfully added to the PDF or with [ERR] if skipped, followed by a percentage indicating the size of the file added to the PDF compared to the original file size.
Vera wrote: And sorry, I forgot to tell you that it doesn't make any difference if all /some or none of the files are marked, always all of them will be processed.

:shock: It's by design.
If you read (again :wink: ) the manual you'll see the checkmarks are used only to select the images you want to remove from the list.
All the files in the list are always processed.

Bye!
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Post by Vera »

luis wrote:
Vera wrote:Doing it all again was not successful to gain a pdf showing the original sized image.
Sorry but I'm not sure to understand what you are saying.
I meant, I tested most settings again but it was unsucsessfull to get a PDF that simply shows the images as they are, without any interfering in size or weight.
luis wrote:1) post a test image somewhere where I could get it
2) post the result pdf (from that image) exibiting the problem
Here's the bundle: testPDFvs1

maybe it's really only due to the file-format

~ Vera
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Vera, it's all looking as it supposed to do to me.

To summarize:

1) The file size

FACT: Any file you drop to i2pdf is re-encoded to JPG with a variable quality (you choose from 1 to 10) or to PNG with lossless quality determined by the algorythm used by the GDI+ library of the OS, and saved internally as a 24 bit image (promoted if needed).

PNG as a target can be a good choice if you have a big BMP in input, with a lot of details you want to preserve at the highest quality.
The PNG will be probably a lot smaller and with the same quality of the source.

If you have a PNG as source, you can keep the same format as target but it will be re-encoded nevertheless.

The image inside the PDF in this case is not really a PNG, but is splitted in a multisegmented RAW image (a format supported by PDF).

Using PNG as source and a PNG as destination sometimes can results in an image larger then the original, especially in your case where you are using very little PNG files at 8 bits, while internally i2pdf works only at 24 bits.

Teoretically would be possible add certain types of images (for example JPG who are natively supported by the PDF format) to the PDF without reprocessing them, and so keeping them of the same exact file size, but that would mean loose the ability to resize them or alter them in any way.
And then it will be only possibile for JPG in practice, not for other formats who are not known to PDF.

So I will not do that, and I'll continue to keep the current method of re-encoding them as needed.

In short: in you examples your files are very small and with 8 BPP, there is not much i2pdf can do to keep them so small considering they have to be re-encoded and promoted internally to 24 BPP.

To keep them so small, i2pdf would need to be able to save to 8 bits formats too. Don't know if I will ever add that possibility.

I'll keep in mind though because maybe for someone scanning exclusively b&w material would be useful. I don't do that, so... we'll see.

2) The dimension in pixels

If you choose to not resize the images, they are saved in the pdf in their original size.
To verify that, you could switch the units used for the PDF viewer you are using from "inches" or "cm" to "points".

If you do so, you will see your image 300x200 is still 300x200 when inside the pdf.

If the image you are viewing is not exactly how you expect (a little larger/smaller) you should look for the resolution settings inside your viewer.

You should find someting like (for example) 72 points for inch. Change this value until you see the image exacly the size you are expecting.
The viewer is using that value to scale the 300x200 image to the resolution of your screen.

The value the OS is returning to the application is never exact at 100%, so usually you see the images a little larger or smaller, usually larger.
PDF viewers works that way, they are not plotting 1 point for 1 pixel like a image viewer usually does.


EDIT Oct 2009: About the 8 bit images. I just did some experiments with 8 bit images inside the PDF. It isn't worth the effort. A good quality JPG ( slider on 8 ) is the same size as a lossless 8 bit PNG and there's not visible difference in the 90% of the cases. So I'll leave the two supported format as they are now.
Last edited by luis on Mon Oct 26, 2009 12:31 am, edited 1 time in total.
Post Reply