Shiny New E-Book Gizmo: The Amazon Kindle


View Full Version : Comics to PDF


Kirys
12-20-2006, 06:59 AM
I've found a nice java library for making pdf (called itext), and i was trying to make a small software for create iliad optimized pdfs from comics scans.
I still not have an ILIAD (i don't know know yet when i'll buy it :P) but i was courious to try the pdf generated with this lib on an iliad.
Is someone iterested it making some experiments?
any suggestion for the ideal image size for the iliad?

Cya

[edit]
Now there is only one pdf generated following most of the suggestions of scotty :)

raevyn1
12-20-2006, 10:47 AM
Your test pdf looks good, Kirys. The comics scale fairly well. Sorry no pix, but I'm currently at work. Tell us some more about iText. Is it easy to use and customize?

jęd
12-20-2006, 10:58 AM
I've attacched a sample pdf i've generated using this lib!

Thats cool... One question... What did the original look like...? Ie, how much alteration did you have to do...?

scotty1024
12-20-2006, 11:26 AM
Here's a screen shot.

Kirys
12-20-2006, 11:37 AM
Your test pdf looks good, Kirys. The comics scale fairly well. Sorry no pix, but I'm currently at work. Tell us some more about iText. Is it easy to use and customize?

http://www.lowagie.com/iText/

Actually I am just aiming at the jpg to pdf application so I don't know all features of the lib yet, till now seems not difficult to use (if you develop in java you should have no problem at all), and powerfull enought for creating also really complex pdfs (is seems also to have some kind of html parser builtin).
I hope to post (if i'm allowed) a first version fo the app soon, but is not yet safe to use yet :P

Thats cool... One question... What did the original look like...? Ie, how much alteration did you have to do...?

Atually The lib don't alter the jpegs itself i made the code (using standard java libs) that scales down the jpegs and set them as grayscale (the version i used for that pdf was bugged and generate a wrong aspect ratio btw), so from that point of view that is fully customizable :).
I've attacched a couple of the source jpeg to let you evaluate the difference.

Here's a screen shot.
seems good :D
Cya

scotty1024
12-20-2006, 02:30 PM
OK, I dug into your actual PDF file and your image scaling is not correct.

Your image is scaled to 1250x1024 and the JPEG for page 2 is 264156 bytes long.

The PDF library is rendering the media box to 14.2" by 17.4" to hold the large image and the iLiad is thus scaling it to make it fit on the screen. You'd do much better to scale the image to a maximum height of 935 using Java's 2D as it has a much better scaling algorithm than the iLiad has at present.

I would also suggest having Java reduce the gray color space to match the iLiad's as well since again Java's 2D package has a better method available.

The iLiad grey values are: 0xf0, 0xe0, 0xd0, 0xc0, 0xb0, 0xa0, 0x90, 0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, 0x00. Future versions of the iLiad (or current users of my enhanced ipdf) treat 0xff the same as 0xf0.

I recommend a media box of 425 by 351.

Based on the large size of the DCTStream I suspect you didn't actually convert the image to a gray scale bitmap in Java 2D, just reduced the colors to gray and left it in a RGB Bitmap. If you convert the image to a gray scale bitmap and feed it to the JPEG encoder you will produce a grey scale JPEG which is considerably smaller than a RGB JPEG as it doesn't need to compress the color space, just crunch down the luminous data.

This will not only reduce the size of the resulting PDF document but in a soon-to-be-released version of Poppler it will result in a considerable savings in decoding time on the iLiad as well.

I personally recommend using http://www.pdfbox.org and I've posted various tools w/Java source here (despite libelous statements about my source code sharing habits made by another member here) that use that library so you can find examples of using it to create iLiad friendly PDF's.

Kirys
12-20-2006, 03:00 PM
OK, I dug into your actual PDF file and your image scaling is not correct.[..]You'd do much better to scale the image to a maximum height of 935 using Java's 2D as it has a much better scaling algorithm than the iLiad has at present.

so the actual available height is 935, and is the width is the full 768?
I've chosed to have the landscape mode as target, cause I don't have yet any idea of how much is readable a comic into standard mode :)


The iLiad grey values are: [..]I recommend a media box of 425 by 351.


Those are really valuable info, that should be into the FAQ :)


Based on the large size of the DCTStream I suspect you didn't actually convert the image to a gray scale bitmap in Java 2D, just reduced the colors to gray and left it in a RGB Bitmap. If you convert the image to a gray scale bitmap and feed it to the JPEG encoder you will produce a grey scale JPEG which is considerably smaller than a RGB JPEG as it doesn't need to compress the color space, just crunch down the luminous data.


this is something that is making me crazy...
this is the first time i'm doing "image manipulation" in java, but following the docs creating the image this way
image = new BufferedImage(width,height,BufferedImage.TYPE_BYTE _GRAY);
should allow the jpeg encoder to generate the grayscale jpeg, but actually it doesn't...


I personally recommend using http://www.pdfbox.org and I've posted various tools w/Java source here (despite libelous statements about my source code sharing habits made by another member here) that use that library so you can find examples of using it to create iLiad friendly PDF's.

I'll take a look
Thank you for your help

Cya

scotty1024
12-20-2006, 03:31 PM
Which Java version are you running? JDK 1.5.0_10, 1.6.0???

Kirys
12-20-2006, 03:38 PM
actually 1.4.2 (under kubuntu linux)
It is the only package available under adept. ;)

Kirys
12-20-2006, 03:46 PM
actually it seems that the jpeg generated is correctly a grayscale jpeg (at least gimp says so)
So maybe is the pdf lib that does something wrong...

scotty1024
12-20-2006, 04:17 PM
Java 2D is much better in 1.5 and much better again in 1.6...

I believe you can get a universal linux java from http://www.javasoft.com that will get you to 1.6.

Kirys
12-21-2006, 02:30 AM
yes I know but most linux users have 1.4.2, I want to stay compatible :) (1.5 is also much faster than 1.4)
Now first I want to make a decent version of the converter with 1.4, then I need to buy my iliad, and maybe by then the linux comunity will start using 1.5 or 1.6 :P

jęd
12-21-2006, 03:58 AM
yes I know but most linux users have 1.4.2, I want to stay compatible :) (1.5 is also much faster than 1.4)
Now first I want to make a decent version of the converter with 1.4, then I need to buy my iliad, and maybe by then the linux comunity will start using 1.5 or 1.6 :P

Well... Since 1.5 is only a download away you may as well go with it... It has some nice features that make life *much* easier... And its not like you can't have multiple JREs co-existing... :D

I'm sure someone who's using Linux and an Iliad is adept enough to install it... :D

Kirys
12-21-2006, 05:09 AM
I do plan making also other softwares that are not only for iliad users :D
I love JAVA :smitten:, but actually under linux manually install j2re and jdk and making them works into the dev enviroment is a real pain, i prefer developing to configuring :D.
Maybe next time i'll be into the right mood (but all this is off topic :p)

coming back to in topic mode
Could someone post some iliad shot with different pages of the second pdf i've posted?

Kirys
12-22-2006, 05:06 AM
I have somekind of a working preview version of the software, can I post it somewhere?

jęd
12-22-2006, 05:30 AM
I have somekind of a working preview version of the software, can I post it somewhere?

If you make a tar ball / zip archive you can post it as an attachment. For longer term projects see http://www.mobileread.com/forums/showthread.php?t=8249 ...

Kirys
12-27-2006, 03:43 AM
well I've uploaded an experimental version into the dev forum :)
At this post (http://www.mobileread.com/forums/showthread.php?t=9125)
I'll upload a better version on friday. If there is enought interest I will develop, making it compatible also with other readers.