当前位置: 首页>>代码示例>>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;未经允许,请勿转载。