Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > PDF

Notices

Reply
 
Thread Tools Search this Thread
Old 08-06-2008, 05:59 AM   #76
Hanselda
Enthusiast
Hanselda began at the beginning.
 
Posts: 42
Karma: 12
Join Date: Feb 2008
Device: CyBook, Sony PRS 600
That is really excellent work. In fact I made something very similar. But I did not go as far as to analyze the image!

Some ideas:
1. Try to use the command pdfimage from pdflib, this can compile all the png images directly into a single PDF. It is much faster than using convert again.

2. Try to quantize the color of the png file. This will reduce the image file size significantly. For e-ink screen the color depth is only 4 - 16, compared to standard 8 bit channel with 256 colors.

3. This method in fact can also work for djvu file. With ddjvu command one can convert certain page into pgm:
'ddjvu -page=%i -scale=%i -format=pgm %s %s' %(pageno, dpi, inputfile, outputfile)
Hanselda is offline   Reply With Quote
Old 08-10-2008, 03:36 AM   #77
kentsin
Junior Member
kentsin began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2008
Device: iphone
I use another pdf and got

page: 1
page: 2
Traceback (most recent call last):
File "/home/kentsin/pi/bin/pi_format.py", line 59, in <module>
test_all(sys.argv[1])
File "/home/kentsin/pi/bin/pi_format.py", line 16, in test_all
doc.reformat()
File "/home/kentsin/pi/bin/pi.py", line 1154, in reformat
page = Page(self, pn)
File "/home/kentsin/pi/bin/pi.py", line 690, in __init__
BasicPage.__init__(self, doc, page_no, dpi)
File "/home/kentsin/pi/bin/pi.py", line 569, in __init__
self.dpi = self.get_dpi()
File "/home/kentsin/pi/bin/pi.py", line 695, in get_dpi
dpi = self.doc.target_width * 50 / width
ZeroDivisionError: float division
kentsin is offline   Reply With Quote
Advert
Old 08-11-2008, 08:59 AM   #78
caritas
Enthusiast
caritas doesn't littercaritas doesn't litter
 
Posts: 26
Karma: 161
Join Date: Feb 2008
Device: Sony PRS505
Version 0.6 is released. Binary and source can be downloaded from the first post of thread.

ChangeLog:

2008-08-11 Huang Ying <ying.huang.caritas@gmail.com>

* Version: 0.6

* pi.py: Initial implementation of embolden.

* pi.py: Use norm coordinate in class Page and Line.

* pi.py: Add edge trimming support.

* pi.py: Add run pages mode.

* pi.py: Add page range support.

* pi.py: Re-work ImageOutput, split multi-page image.

* pi.py: Rotate during scale if approriate.

* img_dir_to_pdf.sh: Add color reduction support.
caritas is offline   Reply With Quote
Old 08-11-2008, 06:03 PM   #79
Gianfranco
computer scientist
Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.
 
Gianfranco's Avatar
 
Posts: 108
Karma: 1587
Join Date: Aug 2008
Location: Gothenburg
Device: Gen 3
I used v0.5 to merge all files into a pdf, but the result was negated. The text was white and the page was black, what could have caused this?

Am I the only one who has experienced it?

Best regards
Gianfranco Alongi

PS: Great tool !
Gianfranco is offline   Reply With Quote
Old 08-12-2008, 04:14 AM   #80
hansl
Zealot
hansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single bookhansl has the entire Project Gutenberg collection on their reader and has corrected every single error in every single book
 
Posts: 112
Karma: 113786
Join Date: Jul 2008
Location: Germany
Device: Sony PRS-T3S, CoolReader on 4'' Android phone
Quote:
Originally Posted by Gianfranco View Post
I used v0.5 to merge all files into a pdf, but the result was negated. The text was white and the page was black, what could have caused this?

Am I the only one who has experienced it?

Best regards
Gianfranco Alongi

PS: Great tool !
I had the same problem and it went away with this fix:

in img_dir_to_pdf.sh line 27 change
tiff2pdf -z -o $cwd/$pdf_fn pdf-$pdf_fn.tiff
to
tiff2pdf -n -z -o $cwd/$pdf_fn pdf-$pdf_fn.tiff

I have not tried but in v0.6 caritas changed that to
tiff2pdf -nz ... so I guess it will work with 0.6 natively

hansl
hansl is offline   Reply With Quote
Advert
Old 08-12-2008, 08:27 AM   #81
Gianfranco
computer scientist
Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.
 
Gianfranco's Avatar
 
Posts: 108
Karma: 1587
Join Date: Aug 2008
Location: Gothenburg
Device: Gen 3
Okay. Nice.
I'll try v 0.6 directly once I come home from work
And once again;;; what a great tool

Maybe you should consider releasing a howto and tutorial on the tool caritas?
Gianfranco is offline   Reply With Quote
Old 08-12-2008, 05:23 PM   #82
Gianfranco
computer scientist
Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.Gianfranco once ate a cherry pie in a record 7 seconds.
 
Gianfranco's Avatar
 
Posts: 108
Karma: 1587
Join Date: Aug 2008
Location: Gothenburg
Device: Gen 3
I used the new release and I am pleased
I wrote about this a little in my blog
Gianfranco is offline   Reply With Quote
Old 08-20-2008, 01:45 AM   #83
xiblack
Junior Member
xiblack began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Aug 2008
Device: iPhone
Quote:
Originally Posted by nrapallo View Post
Overall, pi version 0.3 works well, but I ran into some obstacles trying to 'windows-ize' it.

I succeeded in converting the sample .pdf using 'pi_format chap6.conf' on a Windows PC, but it was a brute-force finish that cannot be used in general. More testing/exploring is required to yield a windows only solution (in addition to the working linux based solution offered by the original poster).

In pi.py, I had to change the bold line to conform with pdftoppm.exe (from xpdf) output of the form "chap6-004-page-000004.pgm" i.e 6 digit page number prior to .pgm.
Code:
def get_img(self, dpi = 150, out_prefix = None):
        pdf_fn = self.doc.pdf_fn
        if out_prefix is None:
            out_prefix = '%spage' % (self.output_prefix,)
        spage = '%d' % (self.page_no,)
        sdpi = '%d' % (dpi,)
        ret = call(['pdftoppm', '-r', sdpi, '-f', spage, '-l', spage, '-gray',
                    pdf_fn, out_prefix])
        assert(ret == 0)
        img_fn = '%s-%06d.pgm' % (out_prefix, self.page_no)
        return img_fn
Hi,

I try the latest pi_06 on my SuSE OSS 10.0.0, it didnt work until I try the fix above.

After the fix, pi_06 works well but I encounter this error after some pages generated:

Quote:
...
page: 30
page: 31
page: 32
Traceback (most recent call last):
File "/home/name/download/pi/bin/pi_format.py", line 67, in ?
test_all(sys.argv[1])
File "/home/name/download/pi/bin/pi_format.py", line 16, in test_all
doc.reformat()
File "/home/name/download/pi/bin/pi.py", line 1495, in reformat
page.rend()
File "/home/name/download/pi/bin/pi.py", line 761, in rend
self.img = self.img.filter(ImageFilter.MinFilter(3))
File "/usr/lib/python2.4/site-packages/PIL/Image.py", line 715, in filter
self.load()
File "/usr/lib/python2.4/site-packages/PIL/ImageFile.py", line 148, in load
self.im = Image.core.map_buffer(
ValueError: buffer is not large enough
I wonder where I can set the buffer larger or is it a limit of anything?

Last edited by xiblack; 08-20-2008 at 01:49 AM.
xiblack is offline   Reply With Quote
Old 08-25-2008, 10:09 AM   #84
ashkulz
Addict
ashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enough
 
ashkulz's Avatar
 
Posts: 350
Karma: 705
Join Date: Dec 2006
Location: Mumbai, India
Device: Kindle 1/REB 1200
pi-0.6 for Win32

I've attached a working version of pi-0.6 which will work under Windows. I had to make a few changes in the code, which have been attached as a diff. Probably caritas could apply them in the next release (they're generic).

Usage: Unzip pi-0.6-win32.zip somewhere and run as instructed above by caritas (You'll need a working Python with PIL installation). In case you want the proper fonts, unzip xpdf-fonts.zip in the same directory and adjust the paths in bin/xpdfrc (right now it's hardcoded to C:\pi).

Enjoy!
Attached Files
File Type: zip pi-0.6-win32.zip (1,017.0 KB, 453 views)
File Type: zip xpdf-fonts.zip (1.15 MB, 444 views)
File Type: txt pi-0.6-win32.patch.txt (1,016 Bytes, 422 views)

Last edited by ashkulz; 08-25-2008 at 10:12 AM.
ashkulz is offline   Reply With Quote
Old 08-25-2008, 10:46 AM   #85
nrapallo
GuteBook/Mobi2IMP Creator
nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.
 
nrapallo's Avatar
 
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
Quote:
Originally Posted by ashkulz View Post
I've attached a working version of pi-0.6 which will work under Windows. I had to make a few changes in the code, which have been attached as a diff. Probably caritas could apply them in the next release (they're generic).

Usage: Unzip pi-0.6-win32.zip somewhere and run as instructed above by caritas (You'll need a working Python with PIL installation). In case you want the proper fonts, unzip xpdf-fonts.zip in the same directory and adjust the paths in bin/xpdfrc (right now it's hardcoded to C:\pi).

Enjoy!
Well done Ashish!

Now I FINALLY can get to try this out (in WinXP) and perhaps incorporate it into PDFRead. Or do you want to do that as I'm at a disadvantage not knowing python as well as you (and it is your original creation)?

Thank you for doing this; I had given up trying to get my windows implementation to work.

BTW, I got a proxy server working for the REB1200 if you are interested. It's in the Fictionwise forum and called Linreb.

Regards,
nrapallo is offline   Reply With Quote
Old 08-30-2008, 03:33 AM   #86
caritas
Enthusiast
caritas doesn't littercaritas doesn't litter
 
Posts: 26
Karma: 161
Join Date: Feb 2008
Device: Sony PRS505
Quote:
Originally Posted by ashkulz View Post
I've attached a working version of pi-0.6 which will work under Windows. I had to make a few changes in the code, which have been attached as a diff. Probably caritas could apply them in the next release (they're generic).
Thank you very much!

I will add it to the next version.
caritas is offline   Reply With Quote
Old 08-30-2008, 04:50 AM   #87
caritas
Enthusiast
caritas doesn't littercaritas doesn't litter
 
Posts: 26
Karma: 161
Join Date: Feb 2008
Device: Sony PRS505
Version 0.7 is released, ChangeLog is as follow:

2008-08-30 Huang Ying <huang.ying.caritas@gmail.com>

* Version: 0.7

* pi.py: Add LRF output support.

* pi.py: Add TOC support for LRF output format

* pi.py: Add output rotate support.

* pdfminfo: Add pdfminfo to extract PDF information such as TOC,
title, author, etc.

* overall: Add initial windows support, thanks ashkulz of
mobileread forum.
caritas is offline   Reply With Quote
Old 08-30-2008, 07:44 PM   #88
ashkulz
Addict
ashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enoughashkulz will become famous soon enough
 
ashkulz's Avatar
 
Posts: 350
Karma: 705
Join Date: Dec 2006
Location: Mumbai, India
Device: Kindle 1/REB 1200
Quote:
Originally Posted by caritas View Post
Version 0.7 is released, ChangeLog is as follow:

2008-08-30 Huang Ying <huang.ying.caritas@gmail.com>

* Version: 0.7

* pi.py: Add LRF output support.

* pi.py: Add TOC support for LRF output format

* pi.py: Add output rotate support.

* pdfminfo: Add pdfminfo to extract PDF information such as TOC,
title, author, etc.

* overall: Add initial windows support, thanks ashkulz of
mobileread forum.
I'm attaching pi_page_parse 0.7 compiled for windows. The usage should be similiar to the 0.6 version (if you want, install 0.6 first and then replace all *.py in the bin folder from the 0.7 version).
Attached Files
File Type: zip pi_page_parse-0.7.zip (6.3 KB, 437 views)
ashkulz is offline   Reply With Quote
Old 09-10-2008, 12:21 PM   #89
nrapallo
GuteBook/Mobi2IMP Creator
nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.
 
nrapallo's Avatar
 
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
I tried ashkulz's win32 executable (v0.6) and obtained great results trying to convert the sample chap6.pdf into my readers native .imp format using PDFRead on the resulting .png in the out folder.

The optimal PDFRead settings used were:

1. In Format 'imgdir'
2. Out Format 'imp2' for EBW1150 or 'imp1' for REB1200. Just substitue your reader's format here instead.
3. Use a 'portrait-p' profile and 'portrait-full' layout mode
4. Check the 'no dilation' box (I tried dilation and since the pi .png's are in a lower resolution it looks terrible!)
5. Click 'Convert'

Looks promising, now only to get that pi algorithm incorporated into PDFRead (with GUI)!
Attached Files
File Type: imp chap6-000001-0_1150_nodilation.imp (2.70 MB, 437 views)
File Type: imp chap6-000001-0_1150_dilation_10pages.imp (189.0 KB, 389 views)
File Type: imp chap6-000001-0_1200_nodilation.imp (4.33 MB, 430 views)
File Type: imp chap6-000001-0_1200_dilation_10pages.imp (344.0 KB, 407 views)

Last edited by nrapallo; 09-12-2008 at 10:20 AM.
nrapallo is offline   Reply With Quote
Old 09-10-2008, 05:12 PM   #90
nrapallo
GuteBook/Mobi2IMP Creator
nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.nrapallo ought to be getting tired of karma fortunes by now.
 
nrapallo's Avatar
 
Posts: 2,958
Karma: 2530691
Join Date: Dec 2007
Location: Toronto, Canada
Device: REB1200 EBW1150 Device: T1 NSTG iLiad_v2 NC Device: Asus_TF Next1 WPDN
Quote:
Originally Posted by nrapallo View Post
I tried ashkulz's win32 executable (v0.6) and obtained great results trying to convert the sample chap6.pdf into my readers native .imp format using PDFRead on the resulting .png in the out folder.

The optimal PDFRead settings used were:

1. In Format 'imgdir'
2. Out Format 'imp2' for EBW1150 or 'imp1' for REB1200. Just substitue your reader's format here instead.
3. Use a 'portrait-p' profile and 'portrait-full' layout mode
4. Check the 'no dilation' box (I tried dilation and since the pi .png's are in a lower resolution it looks terrible!)
5. Click 'Convert'

Looks promising, now only get that pi algorithm incorporated into PDFRead (with GUI)!

Just a note that I attached .lrf and .prc versions of the above sample chap6.pdf here.

This is for the other (popular) small screened ebook readers, Sony PRS-500/505 and Kindle.

Last edited by nrapallo; 09-12-2008 at 10:20 AM.
nrapallo is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My images are disappearing on small screen devices sbrwake Kindle Formats 2 01-10-2009 09:01 PM
Pre-render and cache PDF pages? nekokami iRex 3 07-02-2008 03:26 AM
PDF Text too small! thacursedpie iRex 9 03-18-2008 02:53 PM
Spies can run small devices on body heat. What about eBooks? mogui News 23 09-21-2007 01:31 PM
over 2 mins to render PDF page reh_reh iRex 6 11-11-2006 07:57 AM


All times are GMT -4. The time now is 01:00 AM.


MobileRead.com is a privately owned, operated and funded community.