开发者

phpthumb - disable output

开发者 https://www.devze.com 2023-02-13 17:39 出处:网络
$phpThumb->GenerateThumbnail() or $phpThumb->RenderToFile() create a output with header information and the thumbnail. How can i disable it? I need to store the thumbnail without a return of the thumb

$phpThumb->GenerateThumbnail() or $phpThumb->RenderToFile() create a output with header information and the thumbnail. How can i disable it? I need to store the thumbnail without a return of the thumbnail on the harddisk.

Here is my code:

        require 'class.phpthumb/phpthumb.class.php';
        $phpThumb = new phpThumb();
        $phpThumb->config_temp_directory        = 'thumbnails_c/'; 
        $phpThumb->config_cache_directory       = 'thumbnails_c/'; 
        $phpThumb->config_cache_disable_warning = true;
        $phpThumb->cache_maxage                 = 86400 * 30;
        $phpThumb->cache_maxsize                = 10 * 1024 * 1024;
        $phpThumb->config_cache_force_passthru  = false;            
        $phpThumb->setSourceData($file_data);
        $phpThumb->setParameter('w', 45);
        $phpThumb->setParameter('h', 32);
        $phpThumb->setParameter('zc', 1);
        $phpThumb->setParameter('JPEGquality', 100);
        $phpThumb->setParameter('f', 'jpeg');               

        if ($phpThumb->GenerateThumbnail()) {

            if 开发者_如何学运维($phpThumb->RenderToFile($path_to_the_new_file)) {

                // return the data as an array
                return array(
                    'thumbnail'         => $phpThumb->OutputThumbnail(),
                    'contenttype'       => 'image/jpeg',
                );

            } else {
                // error
                return false;
            }
        } else {
            // error
            return false;
        }

greetings!


From the readme:

Calling as an object (not using phpThumb.php):

NOTE: most people don't need to and should not do this. If you just want to display resized images, please just use phpThumb.php, not the object mode. To render output to one (or more) files instead of the browser, you should skip phpThumb.php and instantiate your own object. Please take a look at /demo/phpThumb.demo.object.php for details.

0

精彩评论

暂无评论...
验证码 换一张
取 消