本文整理汇总了PHP中SimpleImage::rotate_exif方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleImage::rotate_exif方法的具体用法?PHP SimpleImage::rotate_exif怎么用?PHP SimpleImage::rotate_exif使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::rotate_exif方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SimpleImage
function check_size_and_rotation($pathname)
{
require_once mnminclude . "simpleimage.php";
$original = $pathname;
$tmp = "{$pathname}.tmp";
$max_size = 2048;
$image = new SimpleImage();
if ($image->rotate_exif($pathname)) {
if ($image->save($tmp)) {
$pathname = $tmp;
clearstatcache();
}
}
if (filesize($pathname) > 1024 * 1024) {
// Bigger than 1 MB
if ($image->load($pathname) && ($image->getWidth() > $max_size || $image->getHeight() > $max_size)) {
if ($image->getWidth() > $image->getHeight) {
$image->resizeToWidth($max_size);
} else {
$image->resizeToHeight($max_size);
}
if ($image->save($tmp)) {
$pathname = $tmp;
clearstatcache();
}
}
}
if ($pathname != $original && file_exists($pathname)) {
if (!@rename($pathname, $original)) {
syslog(LOG_INFO, "Error renaming file {$pathname} -> {$original}");
@unlink($pathname);
}
}
$this->size = filesize($original);
@chmod($original, 0777);
return true;
}
示例2: uniqid
}
}
}
$tmpfile = $dir . '/' . $current_user->user_id . '-' . $current_user->user_login . '-' . uniqid();
if (file_put_contents($tmpfile, $source)) {
$info = getimagesize($tmpfile);
if (!$info) {
@unlink($tmpfile);
$r->error = _('imagen no soportada');
echo json_encode($r);
die;
}
$ext = image_type_to_extension($info[2]);
$uploadfile = $tmpfile . $ext;
@rename($tmpfile, $uploadfile);
require_once mnminclude . "simpleimage.php";
$image = new SimpleImage();
if ($image->rotate_exif($uploadfile)) {
$image->save($uploadfile);
}
$r->type = $info['mime'];
$r->name = basename($uploadfile);
$r->url = $globals['base_static'] . Upload::get_cache_relative_dir() . '/tmp/' . $r->name;
$r->thumb = $globals['base_static'] . Upload::get_cache_relative_dir() . "/tmp/tmp_thumb-{$r->name}";
// Creates the thumbnail
$thumb = new SimpleImage();
$thumb->load($uploadfile);
$thumb->resize($globals['media_thumb_size'], $globals['media_thumb_size'], true);
$thumb->save(dirname($uploadfile) . "/tmp_thumb-{$r->name}", -1);
echo json_encode($r);
}