Пример #1
0
 function RenderOutput()
 {
     if (!$this->useRawIMoutput && !is_resource($this->gdimg_output)) {
         $this->DebugMessage('RenderOutput() failed because !is_resource($this->gdimg_output)', __FILE__, __LINE__);
         return false;
     }
     if (!$this->thumbnailFormat) {
         $this->DebugMessage('RenderOutput() failed because $this->thumbnailFormat is empty', __FILE__, __LINE__);
         return false;
     }
     if ($this->useRawIMoutput) {
         $this->DebugMessage('RenderOutput copying $this->IMresizedData (' . strlen($this->IMresizedData) . ' bytes) to $this->outputImage', __FILE__, __LINE__);
         $this->outputImageData = $this->IMresizedData;
         return true;
     }
     $builtin_formats = array();
     if (function_exists('ImageTypes')) {
         $imagetypes = ImageTypes();
         $builtin_formats['wbmp'] = (bool) ($imagetypes & IMG_WBMP);
         $builtin_formats['jpg'] = (bool) ($imagetypes & IMG_JPG);
         $builtin_formats['gif'] = (bool) ($imagetypes & IMG_GIF);
         $builtin_formats['png'] = (bool) ($imagetypes & IMG_PNG);
     }
     $this->DebugMessage('RenderOutput() attempting Image' . strtoupper(@$this->thumbnailFormat) . '($this->gdimg_output)', __FILE__, __LINE__);
     ob_start();
     switch ($this->thumbnailFormat) {
         case 'wbmp':
             if (!@$builtin_formats['wbmp']) {
                 $this->DebugMessage('GD does not have required built-in support for WBMP output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality);
             $this->outputImageData = ob_get_contents();
             break;
         case 'jpeg':
         case 'jpg':
             // should be "jpeg" not "jpg" but just in case...
             if (!@$builtin_formats['jpg']) {
                 $this->DebugMessage('GD does not have required built-in support for JPEG output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality);
             $this->outputImageData = ob_get_contents();
             break;
         case 'png':
             if (!@$builtin_formats['png']) {
                 $this->DebugMessage('GD does not have required built-in support for PNG output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImagePNG($this->gdimg_output);
             $this->outputImageData = ob_get_contents();
             break;
         case 'gif':
             if (!@$builtin_formats['gif']) {
                 $this->DebugMessage('GD does not have required built-in support for GIF output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImageGIF($this->gdimg_output);
             $this->outputImageData = ob_get_contents();
             break;
         case 'bmp':
             $ImageOutFunction = '"builtin BMP output"';
             if (!@(include_once dirname(__FILE__) . '/phpthumb.bmp.php')) {
                 $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             $phpthumb_bmp = new phpthumb_bmp();
             $this->outputImageData = $phpthumb_bmp->GD2BMPstring($this->gdimg_output);
             unset($phpthumb_bmp);
             break;
         case 'ico':
             $ImageOutFunction = '"builtin ICO output"';
             if (!@(include_once dirname(__FILE__) . '/phpthumb.ico.php')) {
                 $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             $phpthumb_ico = new phpthumb_ico();
             $arrayOfOutputImages = array($this->gdimg_output);
             $this->outputImageData = $phpthumb_ico->GD2ICOstring($arrayOfOutputImages);
             unset($phpthumb_ico);
             break;
         default:
             $this->DebugMessage('RenderOutput failed because $this->thumbnailFormat "' . $this->thumbnailFormat . '" is not valid', __FILE__, __LINE__);
             ob_end_clean();
             return false;
     }
     ob_end_clean();
     if (!$this->outputImageData) {
         $this->DebugMessage('RenderOutput() for "' . $this->thumbnailFormat . '" failed', __FILE__, __LINE__);
         ob_end_clean();
         return false;
     }
     $this->DebugMessage('RenderOutput() completing with $this->outputImageData = ' . strlen($this->outputImageData) . ' bytes', __FILE__, __LINE__);
     return true;
 }
Пример #2
0
 function RenderOutput()
 {
     if (!$this->useRawIMoutput && !is_resource($this->gdimg_output)) {
         $this->DebugMessage('RenderOutput() failed because !is_resource($this->gdimg_output)', __FILE__, __LINE__);
         return false;
     }
     if (!$this->thumbnailFormat) {
         $this->DebugMessage('RenderOutput() failed because $this->thumbnailFormat is empty', __FILE__, __LINE__);
         return false;
     }
     if ($this->useRawIMoutput) {
         $this->DebugMessage('RenderOutput copying $this->IMresizedData (' . strlen($this->IMresizedData) . ' bytes) to $this->outputImage', __FILE__, __LINE__);
         $this->outputImageData = $this->IMresizedData;
         return true;
     }
     $builtin_formats = array();
     if (function_exists('ImageTypes')) {
         $imagetypes = ImageTypes();
         $builtin_formats['wbmp'] = (bool) ($imagetypes & IMG_WBMP);
         $builtin_formats['jpg'] = (bool) ($imagetypes & IMG_JPG);
         $builtin_formats['gif'] = (bool) ($imagetypes & IMG_GIF);
         $builtin_formats['png'] = (bool) ($imagetypes & IMG_PNG);
     }
     $this->DebugMessage('ImageInterlace($this->gdimg_output, ' . intval($this->config_output_interlace) . ')', __FILE__, __LINE__);
     ImageInterlace($this->gdimg_output, intval($this->config_output_interlace));
     $this->DebugMessage('RenderOutput() attempting Image' . strtoupper(@$this->thumbnailFormat) . '($this->gdimg_output)', __FILE__, __LINE__);
     ob_start();
     switch ($this->thumbnailFormat) {
         case 'wbmp':
             if (empty($builtin_formats['wbmp'])) {
                 $this->DebugMessage('GD does not have required built-in support for WBMP output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality);
             $this->outputImageData = ob_get_contents();
             break;
         case 'jpeg':
         case 'jpg':
             // should be "jpeg" not "jpg" but just in case...
             if (empty($builtin_formats['jpg'])) {
                 $this->DebugMessage('GD does not have required built-in support for JPEG output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality);
             $this->outputImageData = ob_get_contents();
             break;
         case 'png':
             if (empty($builtin_formats['png'])) {
                 $this->DebugMessage('GD does not have required built-in support for PNG output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             if (phpthumb_functions::version_compare_replacement(phpversion(), '5.1.2', '>=')) {
                 // https://github.com/JamesHeinrich/phpThumb/issues/24
                 /* http://php.net/manual/en/function.imagepng.php:
                 			from php source (gd.h):
                 			2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
                 			:: 1 is FASTEST but produces larger files, 9 provides the best
                 			:: compression (smallest files) but takes a long time to compress, and
                 			:: -1 selects the default compiled into the zlib library.
                 			Conclusion: Based on the Zlib manual (http://www.zlib.net/manual.html) the default compression level is set to 6.
                 			*/
                 if ($this->thumbnailQuality >= -1 && $this->thumbnailQuality <= 9) {
                     $PNGquality = $this->thumbnailQuality;
                 } else {
                     $this->DebugMessage('Specified thumbnailQuality "' . $this->thumbnailQuality . '" is outside the accepted range (0-9, or -1). Using 6 as default value.', __FILE__, __LINE__);
                     $PNGquality = 6;
                 }
                 ImagePNG($this->gdimg_output, null, $PNGquality);
             } else {
                 ImagePNG($this->gdimg_output);
             }
             $this->outputImageData = ob_get_contents();
             break;
         case 'gif':
             if (empty($builtin_formats['gif'])) {
                 $this->DebugMessage('GD does not have required built-in support for GIF output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             ImageGIF($this->gdimg_output);
             $this->outputImageData = ob_get_contents();
             break;
         case 'bmp':
             $ImageOutFunction = '"builtin BMP output"';
             if (!@(include_once dirname(__FILE__) . '/phpthumb.bmp.php')) {
                 $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             $phpthumb_bmp = new phpthumb_bmp();
             $this->outputImageData = $phpthumb_bmp->GD2BMPstring($this->gdimg_output);
             unset($phpthumb_bmp);
             break;
         case 'ico':
             $ImageOutFunction = '"builtin ICO output"';
             if (!@(include_once dirname(__FILE__) . '/phpthumb.ico.php')) {
                 $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             $phpthumb_ico = new phpthumb_ico();
             $arrayOfOutputImages = array($this->gdimg_output);
             $this->outputImageData = $phpthumb_ico->GD2ICOstring($arrayOfOutputImages);
             unset($phpthumb_ico);
             break;
         default:
             $this->DebugMessage('RenderOutput failed because $this->thumbnailFormat "' . $this->thumbnailFormat . '" is not valid', __FILE__, __LINE__);
             ob_end_clean();
             return false;
     }
     ob_end_clean();
     if (!$this->outputImageData) {
         $this->DebugMessage('RenderOutput() for "' . $this->thumbnailFormat . '" failed', __FILE__, __LINE__);
         ob_end_clean();
         return false;
     }
     $this->DebugMessage('RenderOutput() completing with $this->outputImageData = ' . strlen($this->outputImageData) . ' bytes', __FILE__, __LINE__);
     return true;
 }
Пример #3
0
 /**
  *
  *
  * @param $GD
  * @param $TargetPath
  */
 public static function imageIco($GD, $TargetPath)
 {
     require_once PATH_LIBRARY . '/vendors/phpThumb/phpthumb.ico.php';
     require_once PATH_LIBRARY . '/vendors/phpThumb/phpthumb.functions.php';
     $Ico = new phpthumb_ico();
     $Arr = array('ico' => $GD);
     $IcoString = $Ico->GD2ICOstring($Arr);
     file_put_contents($TargetPath, $IcoString);
 }
 function RenderOutput()
 {
     if (!$this->useRawIMoutput && !is_resource($this->gdimg_output)) {
         $this->DebugMessage('RenderOutput() failed because !is_resource($this->gdimg_output)', __FILE__, __LINE__);
         return false;
     }
     if (!$this->thumbnailFormat) {
         $this->DebugMessage('RenderOutput() failed because $this->thumbnailFormat is empty', __FILE__, __LINE__);
         return false;
     }
     if ($this->useRawIMoutput) {
         $this->DebugMessage('RenderOutput copying $this->IMresizedData (' . strlen($this->IMresizedData) . ' bytes) to $this->outputImage', __FILE__, __LINE__);
         $this->outputImageData = $this->IMresizedData;
         return true;
     }
     $this->DebugMessage('RenderOutput() attempting Image' . strtoupper(@$this->thumbnailFormat) . '($this->gdimg_output)', __FILE__, __LINE__);
     ob_start();
     switch ($this->thumbnailFormat) {
         case 'jpeg':
             ImageJPEG($this->gdimg_output, null, $this->thumbnailQuality);
             $this->outputImageData = ob_get_contents();
             break;
         case 'png':
             ImagePNG($this->gdimg_output);
             $this->outputImageData = ob_get_contents();
             break;
         case 'gif':
             ImageGIF($this->gdimg_output);
             $this->outputImageData = ob_get_contents();
             break;
         case 'bmp':
             $ImageOutFunction = '"builtin BMP output"';
             if (!@(include_once dirname(__FILE__) . '/phpthumb.bmp.php')) {
                 $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.bmp.php" which is required for BMP format output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             $phpthumb_bmp = new phpthumb_bmp();
             $this->outputImageData = $phpthumb_bmp->GD2BMPstring($this->gdimg_output);
             unset($phpthumb_bmp);
             break;
         case 'ico':
             $ImageOutFunction = '"builtin ICO output"';
             if (!@(include_once dirname(__FILE__) . '/phpthumb.ico.php')) {
                 $this->DebugMessage('Error including "' . dirname(__FILE__) . '/phpthumb.ico.php" which is required for ICO format output', __FILE__, __LINE__);
                 ob_end_clean();
                 return false;
             }
             $phpthumb_ico = new phpthumb_ico();
             $arrayOfOutputImages = array($this->gdimg_output);
             $this->outputImageData = $phpthumb_ico->GD2ICOstring($arrayOfOutputImages);
             unset($phpthumb_ico);
             break;
         default:
             $this->DebugMessage('RenderToFile failed because $this->thumbnailFormat "' . $this->thumbnailFormat . '" is not valid', __FILE__, __LINE__);
             ob_end_clean();
             return false;
     }
     ob_end_clean();
     if (!$this->outputImageData) {
         $this->DebugMessage('RenderOutput() for "' . $this->thumbnailFormat . '" failed', __FILE__, __LINE__);
         ob_end_clean();
         return false;
     }
     $this->DebugMessage('RenderOutput() completing with $this->outputImageData = ' . strlen($this->outputImageData) . ' bytes', __FILE__, __LINE__);
     return true;
 }