PDF-File thumbnails

199 views
Skip to first unread message

martin....@kunst-undwerbedruck.de

unread,
May 16, 2013, 10:21:45 AM5/16/13
to jquery-f...@googlegroups.com
Hi,

i installed imagemagick on our ubuntu server to convert PDF-files to jpg Thumbnails.
Following script converts the files to thumbs with max. 100px height:

convert -resize x100 -pointsize 72 -format jpg -colorspace RGB ../test.pdf test.jpg

How can i implement the script in the uploader to create thumbs the way the uploader creates from jpg-files?

Thank you very much...

Daniel

unread,
May 31, 2013, 4:02:27 PM5/31/13
to jquery-f...@googlegroups.com
UploadHandler.php -> UploadHandler class -> create_scaled_image function

You have to override the image size getter, make a condition to detect or set a fixed size for pdf files and execute this only on non pdf files:
list($img_width, $img_height) = @getimagesize($file_path);

add a boolean i.e. $ispdf (set to false before the switch) 
add a "case" for 'pdf' before the default like this:

case 'pdf'
$ispdf  
= true;
default:
$src_img
= null;

change
return $success;

for something like
if ($ispdf) {
 
exec('command', $output, $return_code);
 
if ($return_code === 0) { $success = true; }
}
return $success;

You can use $options['max_width'] or $options['max_height'] to pass size of thumbnail to imagemagick command OR $new_width and $new_height if you made size getter

Martin F

unread,
Jun 7, 2013, 10:31:23 AM6/7/13
to jquery-f...@googlegroups.com
Thank you very much for your reply.
Could you post the necessary part of the uploadhandler.php?

I don't know where to put this code.
Reply all
Reply to author
Forward
0 new messages