Thumbnail Generation [PDF/DOC/PPT/XLS/Images]
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!!
No comments yet