Generating a Thumbnail by the API
By default, phpThumb generates a thumb the first tim开发者_如何学Goe it is requested. I need to generate it immediately after the image is uploaded to save time when it is requested. I understand that Line 549 of phpThumb.class.php is the focal point of the solution:
$phpThumb->GenerateThumbnail();
However, I'm not sure how much of the surrounding code I should take with it. It looks like I need the next 42 lines (that chain of if's and else's), but, as I'm not familiar with these internals and I couldn't find API documentation for this file, here I am.
(Is there a version number somewhere in the source files that I can post?)
Thanks for any help.
If it's of any use I'm using PHPThumb 3 and have the following PHP code to generate a thumbnail:
<?php
if (!file_exists($thumbnailFile)) {
try {
$thumb = PhpThumbFactory::create($imageFile);
$thumb->adaptiveResize(60, 60);
$thumb->save($thumbnailFile, 'png');
} catch (Exception $e) {
//Zend_Debug::dump($e);
throw new Exception('Issue generating thumbnails');
}
}
Perhaps that's enough for you to adapt to what you need?
精彩评论