本文整理汇总了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));
}
示例2: save
public function save($path)
{
$info = pathinfo($path);
if (!is_dir($info['dirname'])) {
mkdir($info['dirname'], 0777, true);
}
$this->image->save($path);
}
示例3: upload
public function upload()
{
try {
$this->image->save($this->getFullImagePath());
return true;
} catch (\Exception $e) {
$e->getMessage();
//TODO remove once tested
return false;
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例11: save
/**
* Save
*
* @param string $path
* @param integer $quality
*
* @return binary
*/
public function save($path, $quality = null)
{
return $this->image->save($path, $quality);
}
示例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);
}
示例13: save
function save($path)
{
$this->image->save($path . $this->image->filename . '.jpg');
}
示例14: saveImage
public function saveImage($path)
{
$this->image->save($path);
return $this;
}
示例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;
}
}