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 thumb.abc.png

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

$ convert -thumbnail x200 abc.png thumb.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

Step2

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
http://in.php.net/shell_exec

Thats all!!

(Visited 1 times, 1 visits today)
Tags:
Category: LibreOffice, openSUSE, SUSE Linux Enterprise Desktop, Technical Solutions
This entry was posted Tuesday, 8 July, 2008 at 12:13 am
You can follow any responses to this entry via RSS.

Leave a Reply

Your email address will not be published. Required fields are marked *

No comments yet