Page MenuHomePhabricator

"Error generating thumbnail" for a specific PDF file (gs OOM'ing?)
Closed, ResolvedPublic

Description

The following link gives an error instead of a thumbnail:
https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Етнографічний_збірник_Т.28.pdf/page1-7625px-Етнографічний_збірник_Т.28.pdf.jpg

The error message is:

Error creating thumbnail: /bin/bash: line 1: 6515 Done 'gs' -sDEVICE=jpeg -sOutputFile=- -dFirstPage=1 -dLastPage=1 -r150 -dBATCH -dNOPAUSE -q '/tmp/localcopy_e0efc8af0d37-1.pdf'
6516 Killed | 'convert' -depth 8 -resize 7625 - '/tmp/transform_6808bfed72ec-1.jpg'


Version: unspecified
Severity: normal

Details

Reference
bz59668

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:18 AM
bzimport set Reference to bz59668.
bzimport added a subscriber: Unknown Object (MLST).

This can also be a problem in or with the PdfHandler extensions.

Bryan.TongMinh wrote:

My guess would be out-of-memory. Is ImageMagick able to to its memory efficient jpeg resizing algorithm when reading from stdin?

Id guess gs being the thing oom.

The problem is, that the PDF is probably not correct and the GhosScript puts out some messages

wget "https://upload.wikimedia.org/wikipedia/commons/a/a1/%D0%95%D1%82%D0%BD%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D1%96%D1%87%D0%BD%D0%B8%D0%B9_%D0%B7%D0%B1%D1%96%D1%80%D0%BD%D0%B8%D0%BA_%D0%A2.28.pdf" --output-document="testfile.pdf"
# process by gs
gs -sDEVICE=jpeg -sOutputFile=testfile.jpg -dFirstPage=1 -dLastPage=1 -r150 -dBATCH -dNOPAUSE -q 'testfile.pdf'
 **** Warning: glyf overlaps cmap, truncating.
 **** Warning: glyf overlaps cmap, truncating.
 **** Warning: glyf overlaps cmap, truncating.
 **** Warning: glyf overlaps cmap, truncating.
 **** Warning: glyf overlaps cmap, truncating.

ImageMagick consumes these (via | pipe) and consequently ImageMagick fails to process the image, because the text-warning messages are rerouted to ImageMagick. The warning messages are printed to stdout.

I have the same issue https://www.mediawiki.org/wiki/Extension_talk:PdfHandler#Warning_Messages_in_gs_subprocess_fail_image_creation_52766

The solution would be a feature request:

  1. gs should write an intermediary image file
  2. convert uses this intermediary image file instead of pipe input

See also http://bugs.ghostscript.com/show_bug.cgi?id=695600#c3.

I can't reproduce the warnings on a stock mediawiki vagrant VM, sadly, but avoiding the pipe sounds like a sensible thing to do anyway.

I have even tried in my localhost and run perfectly there is no error displaying I think previously this was due to "-dSAFER" actually a bug in ghostscript it can be checked here https://bugs.ghostscript.com/show_bug.cgi?id=691780 , If anyone reproduces please specify?

The test case provided in this task summary renders correctly for me.
Hence closing this task as this problem cannot be reproduced anymore nowadays.
Please reopen and provide links if you can still reproduce this very problem. Thanks!