OpenGroupware Coils Wiki
Status: Beta
Brought to you by:
whitemice
Performed by the coils.blob.autothumb component which creates a set of workers to perform thumbnailing of documents
The PDF thumbnailer uses the convert utility provided by ImageMagick to make and image of the first page of the document
signal.signal(signal.SIGALRM, timeout_alarm_handler)
signal.alarm(CONVERSION_TIMEOUT_SECONDS)
# convert -format pdf -[0] -thumbnail 175x -bordercolor white png:-
converter = Popen(
[
'/usr/bin/convert', '-format', 'pdf', '-[0]',
'-thumbnail', '175x', '-bordercolor', 'white', 'png:-',
],
stdin=PIPE,
stdout=sfile,
)
(converter_in, converter_out, ) = (
converter.stdin, converter.stdout,
)
shutil.copyfileobj(rfile, converter_in)
converter_in.close()
converter.communicate()
signal.alarm(0)
The problem, as always, with using external executables is untraceable dependencies - think fonts - as well as error management. Did it work? If not why not. Is the executable even there? Is it a good version?
Note: we expect the OS to provide a sane installation of convert.
[root@coils-red ~]# rpm -qf /usr/bin/convert
ImageMagick-6.5.4.7-7.el6_5.x86_64
awilliam@linux-86wr:~> cat test.pdf | convert -format pdf -[0] \
-thumbnail 175x -bordercolor white png:file.png
convert: no decode delegate for this image format `/tmp/magick-3499W14ZgJKucF6t' @ error/svg.c/ReadSVGImage/2954.
convert: no images defined `png:file.png' @ error/convert.c/ConvertImageCommand/3187.
awilliam@linux-86wr:~> echo $?
1
awilliam@linux-86wr:~> ls -l file.png
ls: cannot access file.png: No such file or directory
__Coils Log___
2015-06-05T14:55:39:context:DEBUG: duration of document::get-handle was 0.081
2015-06-05T14:55:39:context:DEBUG: converter completed with exit code 1 for OGo#314232599 [Document]
2015-06-05T14:55:39:context:INFO: recording 165b of stderr content from convert for OGo#314232599 [Document] to audit log
2015-06-05T14:55:39:context:INFO: stderr content queued for commit
???
awilliam@linux-86wr:~> cat Downloads/03-december-2014ridershipproductivityreport.pdf \
| convert -format pdf -[0] -thumbnail 175x -bordercolor white png:file.png
awilliam@linux-86wr:~> echo $?
0
awilliam@linux-86wr:~> ls -l file.png
-rw-r--r-- 1 awilliam users 27715 May 6 08:41 file.png