本文整理匯總了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);
}