Ejemplo n.º 1
0
 /**
  * Sets a new logo image by given temp file
  *
  * @param CUploadedFile $file
  */
 public function setNew(CUploadedFile $file)
 {
     $this->delete();
     move_uploaded_file($file->getTempName(), $this->getPath());
     ImageConverter::Resize($this->getPath(), $this->getPath(), array('height' => $this->height, 'width' => 0, 'mode' => 'max', 'transparent' => $file->getExtensionName() == 'png' && ImageConverter::checkTransparent($this->getPath())));
 }
Ejemplo n.º 2
0
 /**
  * Sets a new profile image by given temp file
  *
  * @param CUploadedFile $file
  */
 public function setNew($file)
 {
     $this->delete();
     ImageConverter::TransformToJpeg($file->getTempName(), $this->getPath('_org'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 850, 'mode' => 'max'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
 }
Ejemplo n.º 3
0
 public function getPreviewImageUrl($maxWidth = 1000, $maxHeight = 1000)
 {
     $prefix = 'pi_' . $maxWidth . "x" . $maxHeight;
     // already generated
     if (is_file($this->getPath($prefix))) {
         return $this->getUrl($prefix);
     }
     if ($this->getMimeBaseType() != "image") {
         return "";
     }
     if (!is_file($this->getPath())) {
         return "";
     }
     $imageInfo = getimagesize($this->getPath());
     // Check if we got any dimensions
     if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {
         return "";
     }
     // Check if image type is supported
     if ($imageInfo[2] != IMAGETYPE_PNG && $imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_GIF) {
         return "";
     }
     ImageConverter::Resize($this->getPath(), $this->getPath($prefix), array('mode' => 'max', 'width' => $maxWidth, 'height' => $maxHeight));
     return $this->getUrl($prefix);
 }
Ejemplo n.º 4
0
 public function getPreviewImageUrl($maxWidth = 1000, $maxHeight = 1000)
 {
     $prefix = 'pi_' . $maxWidth . "x" . $maxHeight;
     $originalFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename();
     $previewFilename = $this->getPath() . DIRECTORY_SEPARATOR . $this->getFilename($prefix);
     // already generated
     if (is_file($previewFilename)) {
         return $this->getUrl($prefix);
     }
     // Check file exists & has valid mime type
     if ($this->getMimeBaseType() != "image" || !is_file($originalFilename)) {
         return "";
     }
     $imageInfo = @getimagesize($originalFilename);
     // Check if we got any dimensions - invalid image
     if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {
         return "";
     }
     // Check if image type is supported
     if ($imageInfo[2] != IMAGETYPE_PNG && $imageInfo[2] != IMAGETYPE_JPEG && $imageInfo[2] != IMAGETYPE_GIF) {
         return "";
     }
     ImageConverter::Resize($originalFilename, $previewFilename, array('mode' => 'max', 'width' => $maxWidth, 'height' => $maxHeight));
     return $this->getUrl($prefix);
 }
Ejemplo n.º 5
0
 /**
  * Sets a new profile image by given temp file
  *
  * @param mixed $file CUploadedFile or file path
  */
 public function setNew($file)
 {
     if ($file instanceof CUploadedFile) {
         $file = $file->getTempName();
     }
     $this->delete();
     ImageConverter::TransformToJpeg($file, $this->getPath('_org'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath('_org'), array('width' => 400, 'mode' => 'max'));
     ImageConverter::Resize($this->getPath('_org'), $this->getPath(''), array('width' => $this->width, 'height' => $this->height));
 }