pwang7 / rebook

96 stars 11 forks source link

preview does not work #2

Open Ronggui opened 4 years ago

Ronggui commented 4 years ago

it can generate an image, but not shown in the main window.

pwang7 commented 4 years ago

can you upload a screenshot please?

Ronggui commented 4 years ago

can you upload a screenshot please?

image

pwang7 commented 4 years ago

"No Page 2" means k2pdfopt didn't generate the preview for page 2.

Can you show me the log? Or do you mind to send me the pdf file you're trying to convert?

Ronggui commented 4 years ago

The preview file has been generated, but it cannot be recognized.

"No Page 2" means k2pdfopt didn't generate the preview for page 2.

Can you show me the log?

Or do you mind to send me the pdf file you're trying to convert?

image

image

pwang7 commented 4 years ago

from the log, it showed the preview for the first page generated, it didn't show the preview for the second page generated.

I found the paper you're converting, and I generated the page 2 review successfully, see the first attached picture.

BTW, the page 2 in preview is the second page of the converted PDF file, not of the original PDF file. This is defined by k2pdfopt. The second page of original PDF file is the page 6 of the converted PDF file, see the second attached picture.

Screen Shot 2020-06-28 at 10 46 06 PM

Screen Shot 2020-06-28 at 10 52 40 PM

gameliee commented 4 years ago

It's might because line https://github.com/pwang7/rebook/blob/d322e5d5c3be9a52e22105cbe569df1a0abc30dc/rebook.py#L1709 had tested before the preview was generated. A dirty solution: Comment this line https://github.com/pwang7/rebook/blob/d322e5d5c3be9a52e22105cbe569df1a0abc30dc/rebook.py#L1749

Hope @pwang7 fix it soon

pwang7 commented 4 years ago

It's might because line

https://github.com/pwang7/rebook/blob/d322e5d5c3be9a52e22105cbe569df1a0abc30dc/rebook.py#L1709

had tested before the preview was generated.

This line 1709 is inside function load_preview_image, which is inside a callback preview_image_future_cb. The callback is called when preview is generated or conversion is done: https://github.com/pwang7/rebook/blob/d322e5d5c3be9a52e22105cbe569df1a0abc30dc/rebook.py#L1766

A dirty solution: Comment this line https://github.com/pwang7/rebook/blob/d322e5d5c3be9a52e22105cbe569df1a0abc30dc/rebook.py#L1749

Hope @pwang7 fix it soon

I didn't reproduce the bug. If you reproduce it, could you send me the screenshot and log?

gameliee commented 4 years ago

I tried to convert a 655 pages book to fit kindle ppw3. The book contains a lot of images and math formulas. Here's the log and screenshot

=== Load Preset: {'-dev': ['Kindle Paperwhite 3'], '-screen_unit': ['Pixels'], '-w': ['560'], '-h': ['735'], '-mode': ['Fit Width'], '-o': ['/home/dat/Downloads/rebook/computer vision algorithms and application - Richard Szeliski.pdf'], '-col': [False, '2'], '-dr': [False, '1.0'], '-cbox': [False, '', '0.00', '0.00', '0.00', '0.00'], '-dpi': [False, '167'], '-p': [''], '-fs': [False, '12'], '-ocr': [False, '50'], '-nt': [False, '50'], '-ls': [True, ''], '-ws': [True, '0.200'], '-as': [False], '-bp': [False, False], '-c': [False], '-n': [False], '-r': [False], '-ppgs': [False], '-sm': [False], '-wrap': [True], '-evl': [False], '-ehl': [False], '-rt': [True], '-de': [False], '-ac': [False], '-bmp': []} === Generate Argument List: ['-mode fw', '-ls', '-ws 0.200', '-wrap+', '-rt 0', '-dev kp3', '-a- -ui- -x'] === Current directory: /home/dat/Downloads/rebook === Generate Argument List: ['-mode fw', '-ls', '-ws 0.200', '-wrap+', '-rt 0', '-dev kp3', '-a- -ui- -x'] === ./k2pdfopt "/home/dat/Downloads/rebook/computer vision algorithms and application - Richard Szeliski.pdf" -bmp 1 -mode fw -ls -ws 0.200 -wrap+ -rt 0 -dev kp3 -a- -ui- -x === Preview generation for page 1 finished

screenshot-rebook

pwang7 commented 4 years ago

I found the same book you are converting and built the page 1 review with the same settings as yours. Below is the log and screenshot. I just noticed that you are using the different version of k2pdfopt with mine. From the log output, I'm using k2pdfopt v2.51, compiled Jan 4 2019 with Gnu C v8.2.0 for OS/X on x64. From your log output, it didn't show this version and build info. And from my logout, once k2pdfopt done with preview or conversion, it'll show the CPU consumption. It didn't show this info either from your log output.

=== Load Preset: {'-dev': ['Kindle Oasis 2'], '-screen_unit': ['Pixels'], '-w': ['560'], '-h': ['735'], '-mode': ['2 Columns'], '-o': ['/Users/pwang/Downloads/TOWARDS_A_HIGH-LEVEL_C_ABSTRACTION_TO_UTILIZE_THE_-output.pdf'], '-col': [False, '2'], '-dr': [False, '1.0'], '-cbox': [False, '', '0.00', '0.00', '0.00', '0.00'], '-dpi': [False, '167'], '-p': [''], '-fs': [False, '12'], '-ocr': [False, '50'], '-nt': [False, '50'], '-ls': [False, ''], '-ws': [True, '0.200'], '-as': [False], '-bp': [False, False], '-c': [False], '-n': [False], '-r': [False], '-ppgs': [False], '-sm': [False], '-wrap': [True], '-evl': [False], '-ehl': [False], '-rt': [True], '-de': [False], '-ac': [False], '-bmp': []}
=== Generate Argument List: ['-mode 2col', '-ws 0.200', '-wrap+', '-rt 0', '-dev ko2', '-a- -ui- -x']
=== Current directory: /Users/pwang/Downloads/rebook
=== Generate Argument List: ['-mode fw', '-ws 0.200', '-wrap+', '-rt 0', '-ls', '-dev kp3', '-a- -ui- -x']
=== ./k2pdfopt /Users/pwang/Downloads/SzeliskiBook_20100903_draft.pdf -bmp 1 -mode fw -ws 0.200 -wrap+ -rt 0 -ls -dev kp3 -a- -ui- -x
=== k2pdfopt v2.51 (w/MuPDF,DjVuLibre,OCR) (c) 2019, GPLv3, http://willus.com
=== Compiled Jan  4 2019 with Gnu C v8.2.0 for OS/X on x64.
=== Total CPU time used: 0.93 s
=== Preview generation for page 1 finished

Screen Shot 2020-06-30 at 9 29 00 PM

mustarde commented 4 years ago

I have exactly the same issue, but on Linux. Nothing new, right?

pwang7 commented 4 years ago

I have exactly the same issue, but on Linux. Nothing new, right?

can you upload a screenshot, the log and the parameter settings?

mustarde commented 4 years ago

1 2 @pwang7 I just noticed that it generates a preview image file separately on my desktop (where I am testing the program).

As for the parameters, I tried most of them in different combinations. It's always without the preview.

pwang7 commented 4 years ago

1 2 @pwang7 I just noticed that it generates a preview image file separately on my desktop (where I am testing the program).

As for the parameters, I tried most of them in different combinations. It's always without the preview.

could you send me your pdf file? or the page you want to generate preview?

mustarde commented 4 years ago

abc-export.pdf

Here's a page from the book. But I tried with other pdf files too. I think it's not about the file.

nimamox commented 4 years ago

For me, the problem was that Python on macOS uses Tcl/Tk version 8.5 which apparently does not support PNG files. As upgrading Tcl/Tk and making Python to use that is really cumbersome (Homebrew community is aware of the situation but prefers not to change the formula), I fixed the problem by using Pillow, replacing

        preview_img = PhotoImage(file=img_path)

on line 1710 with

        import PIL.Image
        import PIL.ImageTk
        im = PIL.Image.open(img_path)
        preview_img = PIL.ImageTk.PhotoImage(im)
kmtm commented 3 years ago

If anyone comes here and is still having this issue, I discovered a fix by re-reading how to properly install k2pdfopt on macOS . Instructions here: https://www.willus.com/k2pdfopt/help/mac.shtml - you have to do more than just drag the downloadable file into the rebook folder (--facepalm--).

pwang7 commented 3 years ago

If anyone comes here and is still having this issue, I discovered a fix by re-reading how to properly install k2pdfopt on macOS . Instructions here: https://www.willus.com/k2pdfopt/help/mac.shtml - you have to do more than just drag the downloadable file into the rebook folder (--facepalm--).

Cool!

oasaleh commented 3 years ago

I got the same issue. Any fix available?

sp8996 commented 2 years ago

I got the same issue on linux...then ran chmod +x k2pdfopt in the rebook directory...then everything worked fine.