当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::mime方法代码示例

本文整理汇总了PHP中Intervention\Image\Image::mime方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::mime方法的具体用法?PHP Image::mime怎么用?PHP Image::mime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Intervention\Image\Image的用法示例。


在下文中一共展示了Image::mime方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle request to convert it to a Response object.
  */
 public function handle()
 {
     try {
         if (!$this->request->query->has('image')) {
             throw new FileNotFoundException("No valid image path found in URI", 1);
         }
         $nativePath = $this->configuration->getImagesPath() . '/' . $this->request->query->get('image');
         $this->nativeImage = new File($nativePath);
         $this->parseQuality();
         if ($this->configuration->hasCaching()) {
             $cache = new FileCache($this->request, $this->nativeImage, $this->configuration->getCachePath(), $this->logger, $this->quality, $this->configuration->getTtl(), $this->configuration->getGcProbability(), $this->configuration->getUseFileChecksum());
             $cache->setDispatcher($this->dispatcher);
             /** @var Response response */
             $this->response = $cache->getResponse(function (InterventionRequest $interventionRequest) {
                 return $interventionRequest->processImage();
             }, $this);
         } else {
             $this->processImage();
             $this->response = new Response((string) $this->image->encode(null, $this->quality), Response::HTTP_OK, ['Content-Type' => $this->image->mime(), 'Content-Disposition' => 'filename="' . $this->nativeImage->getFilename() . '"', 'X-Generator-First-Render' => true]);
             $this->response->setLastModified(new \DateTime('now'));
         }
     } catch (FileNotFoundException $e) {
         $this->response = $this->getNotFoundResponse($e->getMessage());
     } catch (\RuntimeException $e) {
         $this->response = $this->getBadRequestResponse($e->getMessage());
     }
 }
开发者ID:ambroisemaupate,项目名称:intervention-request,代码行数:30,代码来源:InterventionRequest.php

示例2: getFormat

 public function getFormat(Image $image)
 {
     $allowed = ['gif' => 'image/gif', 'jpg' => 'image/jpeg', 'pjpg' => 'image/jpeg', 'png' => 'image/png'];
     if (array_key_exists($this->fm, $allowed)) {
         return $this->fm;
     }
     if ($format = array_search($image->mime(), $allowed, true)) {
         return $format;
     }
     return 'jpg';
 }
开发者ID:placers,项目名称:imgproxy,代码行数:11,代码来源:Encode.php

示例3: getFormat

 /**
  * Resolve format.
  * @param  string $format The format.
  * @return string The resolved format.
  */
 public function getFormat(Image $image, $format)
 {
     $allowed = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif'];
     if (in_array($format, $allowed, true)) {
         return $format;
     }
     $mime = $image->mime();
     if (isset($allowed[$mime])) {
         return $allowed[$mime];
     }
     return 'jpg';
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:17,代码来源:Output.php

示例4: make

 /**
  * Save file to database and to our filesystem.
  */
 public static function make(Picture $picture, Image $image, $identifier)
 {
     $file = new self();
     $file->picture_id = $picture->id;
     $file->identifier = $identifier;
     $file->mime = $image->mime();
     $file->extension = $image->extension;
     $file->width = $image->width();
     $file->height = $image->height();
     self::checkDirPermission();
     $image->save($file->getFilePath());
     $file->save();
 }
开发者ID:faltastic,项目名称:Syria-On-The-Move,代码行数:16,代码来源:File.php

示例5: savePicture

 /**
  * Save an Picture object to the file system.
  * Runs OptimizeFileJob on the file after it is saved.
  *
  * @param Picture        $picture
  * @param string         $directory One of the *_DIR constants.
  * @param string         $filename
  * @param ImageFile|null $originalImageFile
  *
  * @throws Exception
  * @return ImageFile
  */
 public function savePicture(Picture $picture, $directory = self::IMAGE_DIR, $filename = null, ImageFile $originalImageFile = null)
 {
     if (!$filename) {
         $mime = $picture->mime();
         if (empty($mime)) {
             $mime = 'image/jpeg';
         }
         $extension = $this->getExtensionForMime($mime);
         $filename = $this->generateFilename($extension);
     }
     $relativePath = $directory . '/' . $filename;
     // Save locally
     if (!$this->savePictureLocally($picture, $relativePath)) {
         throw new Exception('Unable to save file locally.');
     }
     $imageFile = new ImageFile(['originalImageFileId' => $originalImageFile ? $originalImageFile->getId() : null, 'directory' => $directory, 'filename' => $filename, 'width' => $picture->getWidth(), 'height' => $picture->getHeight(), 'size' => $picture->filesize()]);
     $imageFile->save();
     // Optimize and copy to remote storage
     $this->dispatch(new OptimizeFileJob($imageFile));
     return $imageFile;
 }
开发者ID:antriver,项目名称:ctrlv-api,代码行数:33,代码来源:FileManager.php

示例6: getInfo

 public function getInfo()
 {
     return ['mime' => $this->image->mime(), 'width' => $this->image->width(), 'height' => $this->image->height(), 'extension' => $this->image->extension, 'filename' => $this->image->filename, 'filesize' => $this->image->filesize()];
 }
开发者ID:bhutanio,项目名称:laravel-utilities,代码行数:4,代码来源:Imager.php

示例7: guessExtension

 /**
  * Guess extension .
  *
  * @param Image $image
  * @return string
  */
 protected function guessExtension(Image $image)
 {
     $guesser = ExtensionGuesser::getInstance();
     return $guesser->guess($image->mime());
 }
开发者ID:parfumix,项目名称:laravel-image-uploader,代码行数:11,代码来源:ImageProcessor.php

示例8: createDatabaseRecord

 /**
  * Create image record.
  *
  * @return Image
  */
 protected function createDatabaseRecord()
 {
     return Image::create(['hash' => $this->hash, 'mime_type' => $this->image->mime(), 'uploaded_at' => $this->uploaded_at->timestamp]);
 }
开发者ID:BePsvPT,项目名称:CCU,代码行数:9,代码来源:ImageAbstract.php

示例9: buildAssetFromImage

 private function buildAssetFromImage(\Intervention\Image\Image $image, $organization, $name, $type)
 {
     $mime = $image->mime();
     $name = new Name($name);
     $guid = Guid::generate();
     $asset = Asset::register($name, $guid, $mime, $organization);
     $asset->setTitle($name);
     if (isset($type)) {
         $asset->setType($type);
     }
     return $asset;
 }
开发者ID:bakgat,项目名称:notos,代码行数:12,代码来源:AssetsManager.php


注:本文中的Intervention\Image\Image::mime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。