Example #1
0
 public static function resizeByBound($infile, $outfile, $bound)
 {
     $image = AcImage::createImage($infile);
     $image->setRewrite(true);
     $image->hardResize($image->getSize()->getByWidthBound($bound));
     $image->save($outfile);
 }
Example #2
0
 /**
  * @param string путь, по которому будет сохранено изображение
  * @return AcImage
  * @throws FileAlreadyExistsException
  * @throws FileNotSaveException
  */
 public function save($path)
 {
     return parent::saveAsJPG($path);
 }
Example #3
0
 public static function getQuality()
 {
     return 9 - round(parent::getQuality() / 10);
 }
Example #4
0
 /**
  * Наносит лого на изображение.
  *
  * @param mixed
  * @param int номер позиции, в которой будет размещенно лого
  * 0 1
  * 2 3
  * 4 center
  * 
  * @see AcImage::TOP_LEFT
  * @see AcImage::TOP_RIGHT
  * @see AcImage::BOTTOM_LEFT
  * @see AcImage::BOTTOM_RIGHT
  * @see AcImage::CENTER
  * 
  * @return AcImage
  * @throws IllegalArgumentException
  */
 public function drawLogo($logo, $position = null)
 {
     if (is_null($position)) {
         $position = self::$positionLogo;
     }
     if (!AcImage::isCorrectPosition($position)) {
         throw new IllegalArgumentException();
     }
     if (is_string($logo)) {
         $logo = AcImage::createImage($logo);
     }
     if (!$logo instanceof AcImage) {
         throw new IllegalArgumentException();
     }
     $maxWidthLogo = (int) ($this->getWidth() * self::$maxProportionLogo);
     $maxHeightLogo = (int) ($this->getHeight() * self::$maxProportionLogo);
     $logo->resize($maxWidthLogo, $maxHeightLogo);
     if (!self::getTransparency()) {
         $logo->putBackground(self::$backgroundColor);
     }
     imagealphablending($this->getResource(), true);
     $logoSize = $logo->getSize();
     $location = $this->getLogoPosition($position, $logoSize->getWidth(), $logoSize->getHeight());
     imagecopy($this->getResource(), $logo->getResource(), $location->getX(), $location->getY(), 0, 0, $logoSize->getWidth(), $logoSize->getHeight());
     return $this;
 }