/**
  * @param array $options
  *
  * @return bool|null
  */
 public function makeThumbnail($options = array())
 {
     $phpThumb = new modPhpThumb($this->xpdo);
     $phpThumb->initialize();
     $tf = tempnam(MODX_BASE_PATH, 'ms_');
     file_put_contents($tf, $this->file['content']);
     $phpThumb->setSourceFilename($tf);
     foreach ($options as $k => $v) {
         $phpThumb->setParameter($k, $v);
     }
     if ($phpThumb->GenerateThumbnail()) {
         ImageInterlace($phpThumb->gdimg_output, true);
         if ($phpThumb->RenderOutput()) {
             @unlink($phpThumb->sourceFilename);
             @unlink($tf);
             return $phpThumb->outputImageData;
         }
     } else {
         $this->xpdo->log(modX::LOG_LEVEL_ERROR, 'Could not generate thumbnail for "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
     }
     return false;
 }
 /**
  * @param array $options
  * @param array $info
  *
  * @return bool|null
  */
 public function makeThumbnail($options = array(), array $info)
 {
     if (!class_exists('modPhpThumb')) {
         /** @noinspection PhpIncludeInspection */
         require MODX_CORE_PATH . 'model/phpthumb/modphpthumb.class.php';
     }
     /** @noinspection PhpParamsInspection */
     $phpThumb = new modPhpThumb($this->xpdo);
     $phpThumb->initialize();
     $tf = tempnam(MODX_BASE_PATH, 'ms2g_');
     file_put_contents($tf, $info['content']);
     $phpThumb->setSourceFilename($tf);
     foreach ($options as $k => $v) {
         $phpThumb->setParameter($k, $v);
     }
     if ($phpThumb->GenerateThumbnail()) {
         ImageInterlace($phpThumb->gdimg_output, true);
         if ($phpThumb->RenderOutput()) {
             @unlink($phpThumb->sourceFilename);
             @unlink($tf);
             $this->xpdo->log(modX::LOG_LEVEL_INFO, '[ms2Gallery] phpThumb messages for "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
             return $phpThumb->outputImageData;
         }
     }
     @unlink($phpThumb->sourceFilename);
     @unlink($tf);
     $this->xpdo->log(modX::LOG_LEVEL_ERROR, '[ms2Gallery] Could not generate thumbnail for "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
     return false;
 }
 /**
  * @param array $options
  * @param null $raw
  *
  * @return bool|null
  */
 protected function _phpThumb(array $options = array(), $raw = null)
 {
     if ($this->get('type') != 'image') {
         return false;
     } elseif (!class_exists('modPhpThumb')) {
         /** @noinspection PhpIncludeInspection */
         require MODX_CORE_PATH . 'model/phpthumb/modphpthumb.class.php';
     }
     if (empty($raw)) {
         $prepare = $this->prepareSource();
         if ($prepare !== true) {
             return $prepare;
         }
         $filename = $this->get('path') . $this->get('file');
         $info = $this->mediaSource->getObjectContents($filename);
         if (!is_array($info)) {
             return "Could not retrieve contents of file {$filename} from media source.";
         } elseif (!empty($this->mediaSource->errors['file'])) {
             return "Could not retrieve file {$filename} from media source: " . $this->mediaSource->errors['file'];
         }
         $raw = $info['content'];
     }
     $phpThumb = new modPhpThumb($this->xpdo);
     $phpThumb->initialize();
     $tmp = tempnam(MODX_BASE_PATH, 'uf_');
     file_put_contents($tmp, $raw);
     $phpThumb->setSourceFilename($tmp);
     foreach ($options as $k => $v) {
         $phpThumb->setParameter($k, $v);
     }
     if ($phpThumb->GenerateThumbnail()) {
         ImageInterlace($phpThumb->gdimg_output, true);
         if ($phpThumb->RenderOutput()) {
             @unlink($phpThumb->sourceFilename);
             @unlink($tmp);
             $this->xpdo->log(modX::LOG_LEVEL_INFO, '[Uploadify] phpThumb messages for "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
             return $phpThumb->outputImageData;
         }
     }
     @unlink($phpThumb->sourceFilename);
     @unlink($tmp);
     $this->xpdo->log(modX::LOG_LEVEL_ERROR, '[Uploadify] Could not resize "' . $this->get('url') . '". ' . print_r($phpThumb->debugmessages, 1));
     return false;
 }