Example #1
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 #2
0
 public final function isImage($dirs, $fileName, $ext = false)
 {
     return PsImg::isImg($this->absFilePath($dirs, $fileName, $ext));
 }
Example #3
0
 /**
  * @covers PsImg::isImg
  */
 public function testIsImg()
 {
     $this->assertTrue(PsImg::isImg(TestResources::imageGif()));
     $this->assertTrue(PsImg::isImg(TestResources::imagePng()));
     $this->assertTrue(PsImg::isImg(TestResources::imageJpg()));
     $this->assertFalse(PsImg::isImg(TestResources::fakeimagePng()));
     $this->assertFalse(PsImg::isImg(null));
 }
Example #4
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';
 }