Link to home
Start Free TrialLog in
Avatar of coder
coderFlag for Australia

asked on

wand error on python3 ubuntu 18

Hi Experts,

I get the following error on ubuntu python

from wand.image import Image

try:
    from PIL import Image as PILImage
except ImportError:
    import Image as PILImage


wand_pdf_page = Image(filename=wand_temp.name, resolution=96)

Open in new window

I get the following error for executing the last line

Error: /ioerror in --.reusablestreamdecode--
Operand stack:
   --dict:13/21(L)--   --nostringval--   --nostringval--   --dict:4/13(L)--   114194   --nostringval--   --nostringval--   --dict:5/5(L)--   --dict:5/5(L)--   --nostringval--   --dict:0/0(L)--   --nostringval--   --nostringval--   false   false   false   --nostringval--   --nostringval--   --nostringval--   (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000...)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   .reusablestreamdecode   --nostringval--   2   %stopped_push   --nostringval--   .reusablestreamdecode   .reusablestreamdecode   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   2025   1   3   %oparray_pop   2026   1   3   %oparray_pop   .reusablestreamdecode   .reusablestreamdecode   2   1   1   .reusablestreamdecode   %for_pos_int_continue   2029   1   7   %oparray_pop   .reusablestreamdecode   .reusablestreamdecode   false   1   %stopped_push   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   1878   11   9   %oparray_pop   2003   10   9   %oparray_pop   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   %loop_continue   .reusablestreamdecode
Dictionary stack:
   --dict:964/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:133/256(ro)(G)--   --dict:311/450(ro)(G)--   --dict:34/64(L)--   --dict:6/9(L)--   --dict:7/20(L)--
Current allocation mode is global
Last OS error: No such file or directory
GPL Ghostscript 9.26: Unrecoverable error, exit code 1

Open in new window

Any help is highly appreciated.
Please help me in resolving this error.

ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of coder

ASKER

@Dan

Thanks for your response

Please find below the details in the code block

> /home/ts/harvest/extract.py(419)_handle_pdf_new()
-> wand_pdf_page = Image(filename=wand_temp.name, resolution=96)
(Pdb) l
414                             wand_temp = tempfile.NamedTemporaryFile(delete=False, suffix='.pdf')
415                             PdfWriter().addPage(pdf_page).write(wand_temp)
416                             wand_temp.close()
417                             pdb.set_trace()
418
419  ->                         wand_pdf_page = Image(filename=wand_temp.name, resolution=96)
420
421                             print(wand_temp.name)
422
423                             # Resize to ratio
424                             if wand_pdf_page.width > wand_pdf_page.height:
(Pdb) n
Error: /ioerror in --.reusablestreamdecode--
Operand stack:
   --dict:8/17(L)--   --dict:0/1(L)--   0   --dict:8/17(L)--   false   555713   --nostringval--   --nostringval--   --dict:6/6(L)--   --dict:6/6(L)--   --nostringval--   --dict:0/0(L)--   --nostringval--   --nostringval--   false   false   false   --nostringval--   --nostringval--   --nostringval--   (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000...)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   .reusablestreamdecode   --nostringval--   2   %stopped_push   --nostringval--   .reusablestreamdecode   .reusablestreamdecode   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   2025   1   3   %oparray_pop   2026   1   3   %oparray_pop   .reusablestreamdecode   .reusablestreamdecode   2   1   1   .reusablestreamdecode   %for_pos_int_continue   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   %loop_continue   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   1878   12   8   %oparray_pop   2003   11   8   %oparray_pop   .reusablestreamdecode   .reusablestreamdecode   .reusablestreamdecode   %loop_continue   .reusablestreamdecode
Dictionary stack:
   --dict:965/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:133/256(ro)(G)--   --dict:311/450(ro)(G)--   --dict:32/32(L)--   --dict:0/6(L)--
Current allocation mode is global
Last OS error: No such file or directory
GPL Ghostscript 9.26: Unrecoverable error, exit code 1
> /home/ts/harvest/extract.py(421)_handle_pdf_new()
-> print(wand_temp.name)
(Pdb) wand_temp.name
'/tmp/tmp49ls3c7u.pdf'
(Pdb) os._exit(0)
root@2be7443c450a:/tmp# ls -l tmp49ls3c7u.pdf
-rw------- 1 root root 557594 Jun 17 05:17 tmp49ls3c7u.pdf

Open in new window

What I do is extract individual pages of the pdf's with the pdf reader which is by using Mozilla's pdfjs library.  the single page pdf's file exists and it is not zero bytes, but the pdfs are corrupt or blank or not opening with pdf viewer. but few are okay pages

Please suggest what can be done.




Avatar of coder

ASKER

there are problems with pdfs like having security and not properly processed pdf's hence it is failing with Wand Image, Changing the pdfs is the solution