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


PHP ImageInterface::copy方法代码示例

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


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

示例1: __invoke

 public function __invoke($daemon)
 {
     error_log('checking gopro files');
     $imagine = $this->imagine;
     $new = [];
     foreach ($this->gopro->getFiles(GoPro::FILTER_PHOTO) as $file) {
         if (in_array($file->getSequence(), $this->list)) {
             continue;
         }
         $new[] = $file;
     }
     error_log('found files: ' . count($new));
     foreach ($new as $file) {
         error_log('downloading photo: ' . $file->getSequence());
         $content = $this->gopro->download($file);
         error_log('opening photo: ' . $file->getSequence());
         $photo = $imagine->load($content);
         error_log('resizing watermark');
         $watermark = $this->watermark->copy();
         $photoWidth = $photo->getSize();
         $waterSize = $watermark->getSize();
         $newSize = $waterSize->widen($photoWidth->getWidth() - 1);
         $watermark->resize($newSize);
         error_log('adding watermark');
         $pos = new Point(0, $photo->getSize()->getHeight() - $watermark->getSize()->getHeight());
         $photo->paste($watermark, $pos);
         error_log('uploading photo');
         $this->darkroom->upload($file, $photo->get('jpg'));
         error_log('resizing photo');
         $photo->resize(new Box($photo->getSize()->getWidth() / 4, $photo->getSize()->getHeight() / 4));
         error_log('uploading thumb');
         $this->darkroom->upload($file, $photo->get('jpg'), 'th');
         unset($photo);
         unset($watermark);
         $this->list[] = $file->getSequence();
     }
     if (!count($new)) {
         error_log('no new files, waiting a bit');
         sleep(60);
     }
     return true;
 }
开发者ID:nexmo-community,项目名称:javafoto,代码行数:42,代码来源:Developer.php

示例2: createMarkedMediaFile

 /**
  * @param string $mark
  */
 protected function createMarkedMediaFile($mark)
 {
     $Media = $this->Media;
     \Yii::beginProfile(sprintf('create cache file: %s', $Media->id), __METHOD__);
     $this->imagine = Media\components\Image::getImagine()->open(\Yii::getAlias($Media->getAbsolutePath()));
     /** @var MediaModel $MediaModel */
     $MediaModel = \Yii::createObject(MediaModel::class);
     $mark_file_path = $this->getMarkedMediaPath($mark);
     $mark_dir = dirname($mark_file_path);
     if (!file_exists($mark_dir) || !is_dir($mark_dir)) {
         FileHelper::createDirectory($mark_dir, $MediaModel::getMediaModule()->pathChmod);
     }
     $Image = $this->imagine->copy();
     if (!empty($this->handlers)) {
         foreach ($this->handlers as $handler) {
             if (is_callable($handler)) {
                 $Image = $handler($Image);
             }
         }
     }
     $Image->save($mark_file_path, ['quality' => 90]);
     @chmod($mark_file_path, $MediaModel::getMediaModule()->fileChmod);
     \Yii::endProfile(sprintf('create cache file: %s', $Media->id), __METHOD__);
 }
开发者ID:cookyii,项目名称:module-media,代码行数:27,代码来源:ImageWrapper.php

示例3: apply

 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     return $image->copy();
 }
开发者ID:noorafree,项目名称:makmakan,代码行数:7,代码来源:Copy.php

示例4: resize

 /**
  * Executes the actual resizing operation on the Imagine image.
  * In case of an outbound resize the image will be resized and cropped.
  *
  * @param ImagineImageInterface $image
  * @param string $mode
  * @param string $filter
  * @return \Imagine\Image\ManipulatorInterface
  */
 protected function resize(ImagineImageInterface $image, $mode = ImageInterface::RATIOMODE_INSET, $filter = ImagineImageInterface::FILTER_UNDEFINED)
 {
     if ($mode !== ImageInterface::RATIOMODE_INSET && $mode !== ImageInterface::RATIOMODE_OUTBOUND) {
         throw new \InvalidArgumentException('Invalid mode specified');
     }
     $imageSize = $image->getSize();
     $requestedDimensions = $this->calculateDimensions($imageSize);
     $resizedImage = $image->copy();
     $resizedImage->usePalette($image->palette());
     $resizedImage->strip();
     $resizeDimensions = $requestedDimensions;
     if ($mode === ImageInterface::RATIOMODE_OUTBOUND) {
         $resizeDimensions = $this->calculateOutboundScalingDimensions($imageSize, $requestedDimensions);
     }
     $resizedImage->resize($resizeDimensions, $filter);
     if ($mode === ImageInterface::RATIOMODE_OUTBOUND) {
         $resizedImage->crop(new Point(max(0, round(($resizeDimensions->getWidth() - $requestedDimensions->getWidth()) / 2)), max(0, round(($resizeDimensions->getHeight() - $requestedDimensions->getHeight()) / 2))), $requestedDimensions);
     }
     return $resizedImage;
 }
开发者ID:netlogix,项目名称:media,代码行数:29,代码来源:ResizeImageAdjustment.php

示例5: thumbnail

 /**
  * Creates a thumbnail image. The function differs from `\Imagine\Image\ImageInterface::thumbnail()` function that
  * it keeps the aspect ratio of the image.
  * @param Imagine\Image\ImageInterface $Image the image
  * @param integer $width the width in pixels to create the thumbnail
  * @param integer $height the height in pixels to create the thumbnail
  * @param string $mode
  * @return \Imagine\Image\ImageInterface
  */
 public static function thumbnail($Image, $width, $height, $mode = Imagine\Image\ManipulatorInterface::THUMBNAIL_OUTBOUND)
 {
     $box = new Imagine\Image\Box($width, $height);
     $size = $Image->getSize();
     if ($size->getWidth() <= $box->getWidth() && $size->getHeight() <= $box->getHeight() || !$box->getWidth() && !$box->getHeight()) {
         return $Image->copy();
     }
     /** @var Imagine\Image\ImageInterface $Image */
     $Image = $Image->thumbnail($box, $mode);
     $Palette = new Imagine\Image\Palette\RGB();
     // create empty image to preserve aspect ratio of thumbnail
     $thumb = static::getImagine()->create($box, $Palette->color('#ffffff'));
     // calculate points
     $size = $Image->getSize();
     $startX = 0;
     $startY = 0;
     if ($size->getWidth() < $width) {
         $startX = ceil($width - $size->getWidth()) / 2;
     }
     if ($size->getHeight() < $height) {
         $startY = ceil($height - $size->getHeight()) / 2;
     }
     $thumb->paste($Image, new Imagine\Image\Point($startX, $startY));
     return $thumb;
 }
开发者ID:cookyii,项目名称:module-media,代码行数:34,代码来源:Image.php


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