예제 #1
0
 /**
  * @param  string $file
  * @param  string $public
  * @return string
  */
 public function pack($file, $public)
 {
     if (!($file = $this->check($file))) {
         return;
     }
     $image = Image::fromFile($file);
     if ($this->settings['quality'] && !strstr($this->settings['transform'], 'quality,')) {
         $image->quality($this->settings['quality']);
     }
     return $image->transform($this->settings['transform'])->getString();
 }
예제 #2
0
파일: Index.php 프로젝트: oscarotero/folk
 private function thumb(Request $request, Admin $app)
 {
     $query = $request->getQueryParams();
     $thumb = $app->getPath($query['thumb']);
     if (!is_file($thumb)) {
         return Factory::createResponse(404);
     }
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime = finfo_file($finfo, $thumb);
     finfo_close($finfo);
     if ($mime === 'image/svg+xml') {
         return Factory::createResponse()->withBody(Factory::createStream(fopen($thumb, 'r')))->withHeader('Content-Type', $mime);
     }
     $image = Image::fromFile($thumb);
     $image->resize(0, 200);
     echo $image->getString();
     return Factory::createResponse()->withHeader('Content-Type', $image->getMimeType());
 }
예제 #3
0
 private function endImages(array $data)
 {
     if (empty($this->images) || empty($data['id'])) {
         return null;
     }
     clearstatcache();
     foreach ($this->images as $name => $size) {
         if (empty($data[$name])) {
             continue;
         }
         if (!is_file($file = self::getStoragePath($data[$name]))) {
             continue;
         }
         list($width, $height) = explode('x', $size);
         Image::fromFile($file)->resize($width, $height)->save();
     }
 }