SUSE Conversations

Thumbnail Generation [PDF/DOC/PPT/XLS/Images]

By: mendesdomnic

July 8, 2008 12:13 am




Learn how to generate thumbnails at the Linux command prompt.

The article assumes you have Imagemagick and OpenOffice installed on your Linux System.

To generate a thumbnail of an Image:

$ convert -thumbnail 200 abc.png

This will create a thumbnail of the abc.png image with 200px width.

$ convert -thumbnail x200 abc.png

This will create a thumbnail of the abc.png image with 200px height.

To generate a thumbnail of a PDF Document

convert -thumbnail 400x300 test.pdf test.png

This will create a thumbnail of the PDF document with dimensions 400x300px

What if you require a thumbnail of only first page of PDF?
Well, this will do it for you

convert -thumbnail x300 test.pdf[0] test.png

And the following

$ convert -thumbnail x300 test.pdf test.gif

will create an animated gif having all the pages from the PDF document.

To generate a thumbnail of a Word Document

Step 1

/opt/OpenOffice1.1.5/program/soffice -invisible -headless -norestore  "macro:///Standard.Module1.ExportAsPDF("somefile.doc","somefile.pdf")"

Convert Doc to PDF using Open Office


convert -thumbnail x300 somefile.pdf[0] somefile.png

Convert PDF first page to thumbnails.

Hope you will find the above information useful.

You can combine the information above and create a shell script if required. You can also use the above in Web Applications using PHP.

To call a shell script from PHP use shell_exec().

See here for more information on how to execute shell scripts from PHP

Thats all!!

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Categories: LibreOffice, openSUSE, SUSE Linux Enterprise Desktop, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.