本文整理汇总了PHP中Intervention\Image\Image::exif方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::exif方法的具体用法?PHP Image::exif怎么用?PHP Image::exif使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intervention\Image\Image
的用法示例。
在下文中一共展示了Image::exif方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFile
public function setFile($file)
{
$this->file = $file;
$this->image = Image::make($this->file);
$this->iptc = $this->image->iptc();
$this->exif = $this->image->exif();
return $this;
}
示例2: execute
/**
* Correct image orientation according to Exif data
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
switch ($image->exif('Orientation')) {
case 2:
$image->flip();
break;
case 3:
$image->rotate(180);
break;
case 4:
$image->rotate(180)->flip();
break;
case 5:
$image->rotate(270)->flip();
break;
case 6:
$image->rotate(270);
break;
case 7:
$image->rotate(90)->flip();
break;
case 8:
$image->rotate(90);
break;
}
return true;
}
示例3: height
public function height(Image $image)
{
$exif = $image->exif();
$height = isset($exif['ExifImageLength']) ? $exif['ExifImageLength'] : '';
return $height;
}
示例4: exif
/**
* Read Exif data from the current image
*
* Note: Windows PHP Users - in order to use this method you will need to
*
* enable the mbstring and exif extensions within the php.ini file.
*
* @param string $key
* @return mixed
* @static
*/
public static function exif($key = null)
{
return \Intervention\Image\Image::exif($key);
}
示例5: 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));
}