當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Image::save方法代碼示例

本文整理匯總了PHP中Intervention\Image\Image::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Image::save方法的具體用法?PHP Image::save怎麽用?PHP Image::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Intervention\Image\Image的用法示例。


在下文中一共展示了Image::save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 public function process()
 {
     $data = $this->loadData();
     if ($data !== true) {
         return $this->failure($data);
     }
     $mobile = (int) $this->getProperty('mobile', 0);
     if ($mobile == 1) {
         $orientation = $this->img->exif('Orientation');
         switch ($orientation) {
             case 3:
                 $this->img->rotate(180);
                 break;
             case 6:
                 $this->img->rotate(-90);
                 break;
             case 8:
                 $this->img->rotate(90);
                 break;
         }
     }
     if (isset($this->data['rotate'])) {
         $rotate = $this->data['rotate'] * -1.0;
         $this->img->rotate($rotate);
     }
     $crop = $this->getProperty('crop', 0);
     if ($crop == 1 && isset($this->data['width']) && isset($this->data['height'])) {
         $width = intval($this->data['width']);
         $height = intval($this->data['height']);
         if ($height != 0 && $width != 0) {
             $this->img->crop($width, $height, intval($this->data['x']), intval($this->data['y']));
         }
     }
     $fileName = $this->generateUniqueFileName();
     $width = (int) $this->md->getOption('resizer.width', null, 0);
     $width = empty($width) ? null : $width;
     $height = (int) $this->md->getOption('resizer.height', null, 0);
     $height = empty($height) ? null : $height;
     $profileName = $this->getProperty('profile', '');
     if (!empty($profileName) && $crop == 1) {
         $profiles = $this->modx->fromJSON($this->md->getOption('cropper.profiles', null, '[]'));
         foreach ($profiles as $profile) {
             if (!isset($profile['name']) || $profile['name'] != $profileName) {
                 continue;
             }
             $profileWidth = (int) $profile['width'];
             $profileHeight = (int) $profile['height'];
             $width = empty($profileWidth) ? $width : $profileWidth;
             $height = empty($profileHeight) ? $height : $profileHeight;
             break;
         }
     }
     if ($width != null || $height != null) {
         $this->img->resize($width, $height, function ($constraint) {
             /** @var \Intervention\Image\Constraint $constraint */
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     }
     $this->img->save($this->uploadPath . $fileName . '.' . $this->extension);
     return $this->success('', array('path' => $this->uploadURL . $fileName . '.' . $this->extension, 'name' => $this->originalName));
 }
開發者ID:ashliewebb,項目名稱:ashliewebb,代碼行數:62,代碼來源:imageupload.class.php

示例2: save

 public function save($path)
 {
     $info = pathinfo($path);
     if (!is_dir($info['dirname'])) {
         mkdir($info['dirname'], 0777, true);
     }
     $this->image->save($path);
 }
開發者ID:zatsugami,項目名稱:imgen,代碼行數:8,代碼來源:Intervention.php

示例3: upload

 public function upload()
 {
     try {
         $this->image->save($this->getFullImagePath());
         return true;
     } catch (\Exception $e) {
         $e->getMessage();
         //TODO remove once tested
         return false;
     }
 }
開發者ID:orsic,項目名稱:bushido,代碼行數:11,代碼來源:VideoImageUploader.php

示例4: render

 /**
  * Save rendered image to output file
  * @param string $outputImagePath The path to which the image (with text) will be saved
  * @api
  */
 public function render($outputImagePath, $drawtext = true)
 {
     if ($drawtext) {
         $this->drawText();
     }
     $this->image->save($outputImagePath, 100);
 }
開發者ID:nextbigleap,項目名稱:image-with-text,代碼行數:12,代碼來源:Image.php

示例5: save

 /**
  * @param string $path
  * @param null   $quality
  *
  * @return $this
  */
 public function save($path, $quality = null)
 {
     if (!$this->image) {
         throw new \LogicException(sprintf('You must call %s::makeAvatar() first!', __CLASS__));
     }
     $this->image->save($path, $quality);
     return $this;
 }
開發者ID:dsentker,項目名稱:AvatarMaker,代碼行數:14,代碼來源:AvatarMaker.php

示例6: store

 /**
  * Store the image
  *
  * @param  Image  $image [description]
  * @return void
  */
 public function store(Image $image)
 {
     // We can use .htaccess to use that file instead of rerendering
     // the image
     if (!is_dir($this->directory)) {
         mkdir($this->directory);
     }
     $image->save($this->directory . DIRECTORY_SEPARATOR . $this->filename);
 }
開發者ID:nckg,項目名稱:imageme,代碼行數:15,代碼來源:FileSystem.php

示例7: write

 public function write(Image $file, Picture $picture, array $filters = [])
 {
     $filename = $this->buildFileName($picture, $filters);
     $targetPath = 'files/' . $filename;
     $tempFile = storage_path($targetPath . '.jpg');
     $file->save($tempFile);
     $result = $this->getConnection()->write($filename, IlluminateFile::get($tempFile));
     unlink($tempFile);
     return $result;
 }
開發者ID:draperstudio,項目名稱:laravel-picible,代碼行數:10,代碼來源:AbstractAdapter.php

示例8: save

 /**
  * Close the image and save the changes to a file.
  *
  * @param  string|null $destination Destination path where the image should be saved. If it is empty the original image file will be overwritten.
  * @throws \RuntimeException
  * @return Image  image or false, based on success.
  */
 public function save($destination = null)
 {
     if (empty($destination)) {
         $destination = $this->source;
     }
     $this->image->save($destination);
     // Clear the cached file size and refresh the image information.
     clearstatcache();
     chmod($destination, 0644);
     return new self($destination);
 }
開發者ID:onigoetz,項目名稱:imagecache,代碼行數:18,代碼來源:Image.php

示例9: writeThumb

 /**
  * Write the re-sized image to the destination path,
  * creating any relative directories necessary.
  *
  * @param $dst_path
  * @param ImageManipulator $image
  * @return bool|Image
  */
 private function writeThumb($dst_path, ImageManipulator $image)
 {
     $parts = explode('/', $dst_path);
     array_pop($parts);
     $path = implode('/', $parts);
     if (!file_exists($path)) {
         if (!mkdir($path, 0775)) {
             return false;
         }
     }
     return $image->save($dst_path);
 }
開發者ID:ftdysa,項目名稱:website,代碼行數:20,代碼來源:ResizeImagesCommand.php

示例10: 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

示例11: save

 /**
  * Save
  *
  * @param string  $path
  * @param integer $quality
  *
  * @return binary
  */
 public function save($path, $quality = null)
 {
     return $this->image->save($path, $quality);
 }
開發者ID:naturalweb,項目名稱:nwlaravel,代碼行數:12,代碼來源:Imagine.php

示例12: saveImage

 /**
  * @param Image $image
  */
 public function saveImage(Image $image)
 {
     $path = dirname($this->cacheFilePath);
     if (!file_exists($path)) {
         mkdir($path, 0777, true);
     }
     $image->save($this->cacheFilePath, $this->quality);
 }
開發者ID:ambroisemaupate,項目名稱:intervention-request,代碼行數:11,代碼來源:FileCache.php

示例13: save

 function save($path)
 {
     $this->image->save($path . $this->image->filename . '.jpg');
 }
開發者ID:orsic,項目名稱:bushido,代碼行數:4,代碼來源:Video.php

示例14: saveImage

 public function saveImage($path)
 {
     $this->image->save($path);
     return $this;
 }
開發者ID:katzefudder,項目名稱:Photoindexer,代碼行數:5,代碼來源:ImageHandler.php

示例15: createDocumentFromImage

 /**
  * @param  Image    $processImage
  * @param  Document $rawDocument
  * @return Document
  */
 protected function createDocumentFromImage(Image $processImage, Document $originalDocument, $keepExistingRaw = false)
 {
     $fs = new Filesystem();
     if (false === $keepExistingRaw && null !== ($formerRawDoc = $originalDocument->getRawDocument())) {
         /*
          * When document already exists with a raw doc reference.
          * We have to delete former raw document before creating a new one.
          * Keeping the same document to preserve existing relationships!!
          */
         $originalDocument->setRawDocument(null);
         /*
          * Make sure to disconnect raw document before removing it
          * not to trigger Cascade deleting.
          */
         $this->em->flush();
         $this->em->remove($formerRawDoc);
         $this->em->flush();
     }
     if (null === $originalDocument->getRawDocument() || $keepExistingRaw === false) {
         /*
          * We clone it to host raw document.
          * Keeping the same document to preserve existing relationships!!
          *
          * Get every data from raw document.
          */
         $rawDocument = clone $originalDocument;
         $rawDocumentName = preg_replace('#\\.(jpe?g|gif|tiff?|png|psd)$#', $this->rawImageSuffix . '.$1', $originalDocument->getFilename());
         $rawDocument->setFilename($rawDocumentName);
         if ($fs->exists($originalDocument->getAbsolutePath()) && !$fs->exists($rawDocument->getAbsolutePath())) {
             /*
              * Original document path becomes raw document path. Rename it.
              */
             $fs->rename($originalDocument->getAbsolutePath(), $rawDocument->getAbsolutePath());
             /*
              * Then save downscaled image as original document path.
              */
             $processImage->save($originalDocument->getAbsolutePath(), 100);
             $originalDocument->setRawDocument($rawDocument);
             $rawDocument->setRaw(true);
             $this->em->persist($rawDocument);
             $this->em->flush();
             return $originalDocument;
         } else {
             return false;
         }
     } else {
         /*
          * We keep intact raw document, just updating downscaled doc.
          */
         $rawDocument = $originalDocument->getRawDocument();
         /*
          * Remove existing downscaled document.
          */
         $fs->remove($originalDocument->getAbsolutePath());
         /*
          * Then save downscaled image as original document path.
          */
         $processImage->save($originalDocument->getAbsolutePath(), 100);
         $this->em->flush();
         return $originalDocument;
     }
 }
開發者ID:QuangDang212,項目名稱:roadiz,代碼行數:67,代碼來源:DownscaleImageManager.php


注:本文中的Intervention\Image\Image::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。