rebook icon indicating copy to clipboard operation
rebook copied to clipboard

preview does not work

Open Ronggui opened this issue 4 years ago • 19 comments

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

Ronggui avatar Jun 17 '20 06:06 Ronggui

can you upload a screenshot please?

pwang7 avatar Jun 18 '20 11:06 pwang7

can you upload a screenshot please?

image

Ronggui avatar Jun 24 '20 04:06 Ronggui

"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?

pwang7 avatar Jun 24 '20 05:06 pwang7

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

Ronggui avatar Jun 27 '20 03:06 Ronggui

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

pwang7 avatar Jun 28 '20 14:06 pwang7

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

gameliee avatar Jun 29 '20 08:06 gameliee

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?

pwang7 avatar Jun 29 '20 12:06 pwang7

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

gameliee avatar Jun 30 '20 02:06 gameliee

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

pwang7 avatar Jun 30 '20 13:06 pwang7

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

mustarde avatar Jul 19 '20 13:07 mustarde

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

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

pwang7 avatar Jul 19 '20 14:07 pwang7

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.

mustarde avatar Jul 19 '20 16:07 mustarde

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?

pwang7 avatar Jul 20 '20 05:07 pwang7

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.

mustarde avatar Jul 20 '20 07:07 mustarde

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)

nimamox avatar Aug 18 '20 01:08 nimamox

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--).

kmtm avatar Mar 21 '21 06:03 kmtm

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!

pwang7 avatar Mar 21 '21 08:03 pwang7

I got the same issue. Any fix available?

oasaleh avatar Apr 28 '21 18:04 oasaleh

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

sp8996 avatar May 29 '22 15:05 sp8996