Example #1
0
 /**
  * Метод добавляет картинку в анимацию
  */
 public function addImg($path, $delay = 40)
 {
     if ($path instanceof DirItem) {
         $path = $path->getAbsPath();
     }
     PsImg::assertIsImg($path);
     $this->IMAGES[$path] = $delay;
     unset($this->animation);
 }
Example #2
0
 private function __construct($name, Spritable $spritable)
 {
     $this->LOGGER = PsLogger::inst(__CLASS__);
     $this->spritable = $spritable;
     $this->name = $name;
     $this->cssDi = self::autogenWs($name)->getDirItem(null, $name, 'css');
     $this->imgDi = self::autogenWs($name)->getDirItem(null, $name, PsImg::getExt(SYSTEM_IMG_TYPE));
     $this->LOGGER->info("INSTANCE CREATED FOR [{$name}]");
     $this->rebuild(false);
 }
Example #3
0
 /**
  * Все допустимые mime-типы картинок
  * Array (image/jpeg, image/gif, image/png)
  */
 public static function MIMES()
 {
     if (!is_array(self::$MIMES)) {
         self::$MIMES = array();
         foreach (self::TYPES() as $type) {
             self::$MIMES[] = strtolower(image_type_to_mime_type($type));
         }
     }
     return self::$MIMES;
 }
Example #4
0
 public function createSmallCovers($forceRecr = false)
 {
     /* @var $ex GymEx */
     foreach ($this->getExercises() as $ex) {
         $curImg = $this->absCoverPath($ex->getId());
         if (!PsImg::isImg($curImg)) {
             continue;
         }
         $imgNew = $this->absCoverPathSmall($ex->getId());
         if (!PsImg::isImg($imgNew) || $forceRecr) {
             SimpleImage::inst()->load($curImg)->resizeSmart($this->dim, $this->dim)->save($imgNew)->close();
         }
     }
 }
Example #5
0
 public final function isImage($dirs, $fileName, $ext = false)
 {
     return PsImg::isImg($this->absFilePath($dirs, $fileName, $ext));
 }
Example #6
0
 public function assertIsImg()
 {
     $this->assertIsValid();
     PsImg::assertIsImg($this->getTmpFilePath());
 }
Example #7
0
 /**
  * @covers PsImg::assertIsImg
  */
 public function testAssertIsImg()
 {
     PsImg::assertIsImg(TestResources::imageGif());
     PsImg::assertIsImg(TestResources::imagePng());
     PsImg::assertIsImg(TestResources::imageJpg());
     try {
         PsImg::assertIsImg(TestResources::fakeimagePng());
         $this->brakeNoException();
     } catch (PException $ex) {
     }
 }
Example #8
0
 public function getMime()
 {
     $this->assertIsFile(__FUNCTION__);
     $file = $this->absPath;
     if (PsImg::isImg($file)) {
         return array_get_value('mime', getimagesize($file));
     }
     if (function_exists("finfo_file")) {
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         // return mime type ala mimetype extension
         $mime = finfo_file($finfo, $file);
         finfo_close($finfo);
         return $mime;
     } else {
         if (function_exists("mime_content_type")) {
             return mime_content_type($file);
         } else {
             if (!stristr(ini_get("disable_functions"), "shell_exec")) {
                 // http://stackoverflow.com/a/134930/1593459
                 $file = escapeshellarg($file);
                 $mime = shell_exec("file -bi " . $file);
                 return $mime ? $mime : 'unknown';
             }
         }
     }
     return 'unknown';
 }
Example #9
0
 /** @return SimpleImage */
 public function output($type = IMAGETYPE_JPEG, $path = null)
 {
     $code = PsImg::getType($type);
     switch ($code) {
         case IMAGETYPE_JPEG:
             imagejpeg($this->image, $path, 100);
             break;
         case IMAGETYPE_GIF:
             imagegif($this->image, $path);
             break;
         case IMAGETYPE_PNG:
             imagepng($this->image, $path);
             break;
     }
     return $this;
 }