本文整理汇总了PHP中imagerotate函数的典型用法代码示例。如果您正苦于以下问题:PHP imagerotate函数的具体用法?PHP imagerotate怎么用?PHP imagerotate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imagerotate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: orientate
/**
* Orientate the image.
*
* @param UploadedFile $file
* @param $orientation
* @return UploadedFile
*/
protected function orientate(UploadedFile $file, $orientation)
{
$image = imagecreatefromjpeg($file->getRealPath());
switch ($orientation) {
case 2:
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 3:
$image = imagerotate($image, 180, 0);
break;
case 4:
$image = imagerotate($image, 180, 0);
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 5:
$image = imagerotate($image, -90, 0);
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
case 7:
$image = imagerotate($image, 90, 0);
imageflip($image, IMG_FLIP_HORIZONTAL);
break;
case 8:
$image = imagerotate($image, 90, 0);
break;
}
imagejpeg($image, $file->getRealPath(), 90);
return new UploadedFile($file->getRealPath(), $file->getClientOriginalName(), $file->getMimeType(), $file->getSize());
}
开发者ID:AkibaTech,项目名称:files-module,代码行数:39,代码来源:FileRotator.php
示例2: rotate
/**
* rotate image
*/
public static function rotate($filename)
{
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
switch ($extension) {
case 'gif':
$img_r = imagecreatefromgif($filename);
$dst_r = imagerotate($img_r, -90, 0);
imagegif($dst_r, $filename);
break;
case 'jpg':
case 'jpeg':
$img_r = imagecreatefromjpeg($filename);
$dst_r = imagerotate($img_r, -90, 0);
imagejpeg($dst_r, $filename, 75);
break;
case 'png':
$img_r = imagecreatefrompng($filename);
$dst_r = imagerotate($img_r, -90, 0);
imagealphablending($dst_r, false);
imagesavealpha($dst_r, true);
imagepng($dst_r, $filename, 9);
break;
default:
return false;
}
return true;
}
开发者ID:georgepaul,项目名称:songslikesocial,代码行数:30,代码来源:ImageLib.php
示例3: rotate
public function rotate($path, $degrees)
{
header('Content-type: image/png');
$source = imagecreatefrompng($path);
$rotate = imagerotate($source, $degrees, 0);
imagepng($rotate, $path);
}
开发者ID:gameNaJa,项目名称:natkaset,代码行数:7,代码来源:C_service.php
示例4: applyFilter
/**
* (non-PHPdoc)
* @see \imagemanipulation\filter\IImageFilter::applyFilter()
*/
public function applyFilter(ImageResource $resource)
{
if ($this->radius === 0) {
return;
}
$source_image = $resource->getResource();
$source_width = $resource->getX();
$source_height = $resource->getY();
$corner_image = imagecreatetruecolor($this->radius, $this->radius);
$clear_colour = imagecolorallocate($corner_image, 0, 0, 0);
imagecolortransparent($corner_image, $clear_colour);
$solid_colour = imagecolorallocate($corner_image, $this->color->getRed(), $this->color->getGreen(), $this->color->getBlue());
imagefill($corner_image, 0, 0, $solid_colour);
imagefilledellipse($corner_image, $this->radius, $this->radius, $this->radius * 2, $this->radius * 2, $clear_colour);
/*
* render the top-left, bottom-left, bottom-right, top-right corners by rotating and copying the mask
*/
imagecopymerge($source_image, $corner_image, 0, 0, 0, 0, $this->radius, $this->radius, 100);
$corner_image = imagerotate($corner_image, 90, 0);
imagecopymerge($source_image, $corner_image, 0, $source_height - $this->radius, 0, 0, $this->radius, $this->radius, 100);
$corner_image = imagerotate($corner_image, 90, 0);
imagecopymerge($source_image, $corner_image, $source_width - $this->radius, $source_height - $this->radius, 0, 0, $this->radius, $this->radius, 100);
$corner_image = imagerotate($corner_image, 90, 0);
imagecopymerge($source_image, $corner_image, $source_width - $this->radius, 0, 0, 0, $this->radius, $this->radius, 100);
}
开发者ID:dreamsxin,项目名称:imagemanipulation,代码行数:29,代码来源:ImageFilterRoundedCorners.php
示例5: setImageFile
/**
* Set image resource from file
*
* @param string $file Path to image file
* @return ImageManipulator for a fluent interface
* @throws InvalidArgumentException
*/
public function setImageFile($file, $ios)
{
if (!(is_readable($file) && is_file($file))) {
throw new InvalidArgumentException("Image file {$file} is not readable");
}
if (is_resource($this->image)) {
imagedestroy($this->image);
}
list($this->width, $this->height, $type) = getimagesize($file);
switch ($type) {
case IMAGETYPE_GIF:
$tmp = imagecreatefromgif($file);
break;
case IMAGETYPE_JPEG:
$tmp = imagecreatefromjpeg($file);
break;
case IMAGETYPE_PNG:
$tmp = imagecreatefrompng($file);
break;
default:
throw new InvalidArgumentException("Image type {$type} not supported");
}
if ($ios) {
$this->image = imagerotate($tmp, 270, 0);
imagedestroy($tmp);
} else {
$this->image = $tmp;
}
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
return $this;
}
开发者ID:brandmobility,项目名称:kikbak,代码行数:39,代码来源:ImageManipulator.php
示例6: flip
/**
* 修改一个图片 让其翻转指定度数
*
* @param string $filename 文件名(包括文件路径)
* @param string $src 输出文件名(包括文件路径)
* @param float $degrees 旋转度数 -90顺时针 90逆时针
*/
function flip($filename, $src, $degrees = 90)
{
//读取图片
$data = @getimagesize($filename);
if ($data == false) {
return false;
}
//读取旧图片
switch ($data[2]) {
case 1:
$src_f = imagecreatefromgif($filename);
break;
case 2:
$src_f = imagecreatefromjpeg($filename);
break;
case 3:
$src_f = imagecreatefrompng($filename);
break;
}
if ($src_f == "") {
return false;
}
$rotate = @imagerotate($src_f, $degrees, 0);
if (!imagejpeg($rotate, $src, 100)) {
return false;
}
@imagedestroy($rotate);
return true;
}
开发者ID:279838089,项目名称:upload_pictur,代码行数:36,代码来源:upload.php
示例7: fixOrientation
public function fixOrientation()
{
if (exif_imagetype($this->image) == 2) {
$exif = exif_read_data($this->image);
if (array_key_exists('Orientation', $exif)) {
$orientation = $exif['Orientation'];
$images_orig = ImageCreateFromJPEG($this->image);
$rotate = "";
switch ($orientation) {
case 3:
$rotate = imagerotate($images_orig, 180, 0);
break;
case 6:
$rotate = imagerotate($images_orig, -90, 0);
break;
case 8:
$rotate = imagerotate($images_orig, 90, 0);
break;
}
if ($rotate != "") {
ImageJPEG($rotate, $this->image);
ImageDestroy($rotate);
}
ImageDestroy($images_orig);
}
}
}
开发者ID:HyuchiaDiego,项目名称:Kirino,代码行数:27,代码来源:Image.php
示例8: rotate
public function rotate($angle)
{
$this->_imageHandler = imagerotate($this->_imageHandler, $angle, -1);
imagealphablending($this->_imageHandler, true);
imagesavealpha($this->_imageHandler, true);
$this->refreshImageDimensions();
}
开发者ID:Eximagen,项目名称:BulletMagento,代码行数:7,代码来源:Gd2.php
示例9: _rotate
protected function _rotate($degrees)
{
extract(parent::_rotate($degrees));
$degrees = 360 - $degrees;
$color = $this->create_color($this->image_data, $this->config['bgcolor'], 1000);
$this->image_data = imagerotate($this->image_data, $degrees, $color, false);
}
开发者ID:bryanheo,项目名称:FuelPHP-Auth-AJAX,代码行数:7,代码来源:gd.php
示例10: __construct
/**
* Create a new captcha.
*
* @param integer $characters The amount of characters to show.
* @param integer $width
* @param integer $height
*
* @return image resource
*/
public function __construct($characters = 10, $width = 145, $height = 65)
{
$this->captcha = new Captcha_Text($characters, $width - 2, $height / 2.8);
$im = imagecreatetruecolor($width, $height);
$noise_color = imagecolorallocate($im, 131, 131, 131);
$background_color = imagecolorallocate($im, 244, 0, 0);
imagefill($im, 0, 0, $background_color);
// Fetch captcha text
$cpt = $this->captcha->getImage();
$w = imagesx($cpt);
$h = imagesy($cpt);
// Rotate captcha text
$cpt2 = imagerotate($cpt, rand(1, 20), rand(1, 9));
imagecopy($im, $cpt2, rand(1, 5), rand(1, 6), rand(1, 5), rand(1, 6), $width, $height);
// Make some noise.
for ($i = 0; $i < $width * $height / 6; $i++) {
imagefilledellipse($im, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
}
//$im = imagerotate($im, rand(0, 30), rand(0, 5));
// Assign captcha
$this->render = $im;
// Clean used images
imagedestroy($cpt);
imagedestroy($cpt2);
}
开发者ID:rszabo,项目名称:egalite,代码行数:34,代码来源:Captcha.php
示例11: render_text_on_gd_image
function render_text_on_gd_image($target, $imgSize, $text, $font, $size, $color, $opacity, $rotation)
{
$im = imagecreatetruecolor($imgSize[0], $imgSize[1]);
//$black = imagecolorallocate($im, 0, 0, 0);
//imagecolortransparent($im, $black);
imagealphablending($im, false);
imagesavealpha($im, true);
$transparent = imagecolorallocatealpha($im, 255, 255, 255, 127);
imagefill($im, 0, 0, $transparent);
//imagecolortransparent($im, $transparent);
$source_width = $imgSize[0];
$source_height = $imgSize[1];
$bb = $this->imagettfbbox_fixed($size, 0, $font, $text);
$x = $bb[0] + $imgSize[0] / 2 - $bb[4] / 2 - 5;
$y = $bb[1] + $imgSize[1] / 2 - $bb[5] / 2 - 5;
$alpha_color = imagecolorallocatealpha($im, $color[0], $color[1], $color[2], 127 * (100 - $opacity) / 100);
imagettftext($im, $size, 0, $x, $y, $alpha_color, $font, $text);
if ($rotation != 0) {
$new = imagerotate($im, $rotation, $transparent);
imagealphablending($new, false);
imagesavealpha($new, true);
imagedestroy($im);
$im = $new;
}
/*$newWidth = imagesx($tmpImage);
$newHt = imagesy($tmpImage);
imagecopymerge($image, $tmpImage, $x - $newWidth + $dropdown, $y - $newHt, 0, 0, $newWidth, $newHt, 100);*/
imagepng($im, $target);
imagedestroy($im);
return TRUE;
}
开发者ID:mobas,项目名称:mollify,代码行数:31,代码来源:ImageGenerator.class.php
示例12: imgrotate
function imgrotate($dir, $sens)
{
$src = imagecreatefromjpeg($dir);
// Rotation
$rotate = imagerotate($src, $sens, 0);
return imagejpeg($rotateFull, $dir, 100);
}
开发者ID:rodbox,项目名称:rodbox3,代码行数:7,代码来源:appController.php
示例13: execute
/**
* Returns rotated image
*
* @param WideImage_Image $image
* @param numeric $angle
* @param int $bgColor
* @param bool $ignoreTransparent
* @return WideImage_Image
*/
function execute($image, $angle, $bgColor, $ignoreTransparent)
{
$angle = -floatval($angle);
if ($angle < 0) {
$angle = 360 + $angle;
}
$angle = $angle % 360;
if ($angle == 0) {
return $image->copy();
}
if ($bgColor === null) {
if ($image->isTransparent()) {
$bgColor = $image->getTransparentColor();
} else {
$tc = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127);
if ($image->isTrueColor()) {
$bgColor = $image->getExactColorAlpha($tc);
if ($bgColor == -1) {
$bgColor = $image->allocateColorAlpha($tc);
}
} else {
$bgColor = $image->getExactColor($tc);
if ($bgColor == -1) {
$bgColor = $image->allocateColor($tc);
}
}
}
}
return new WideImage_TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent));
}
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:39,代码来源:Rotate.php
示例14: save
function save($filename, $image_type = 2, $compression = 80, $permissions = null)
{
if ($image_type == 2) {
//jpg
$exif = exif_read_data($filename);
$ort = 1;
if (isset($exif['Orientation'])) {
$ort = $exif['Orientation'];
}
if ($ort == 3) {
$this->image = imagerotate($this->image, 180, -1);
} else {
if ($ort == 5 || $ort == 6 || $ort == 7) {
$this->image = imagerotate($this->image, -90, -1);
} else {
if ($ort == 8) {
$this->image = imagerotate($this->image, 90, -1);
}
}
}
imagejpeg($this->image, $filename);
//imagejpeg($this->image,$filename,$compression);
} elseif ($image_type == 1) {
//gif
imagegif($this->image, $filename);
} elseif ($image_type == 3) {
//png
imagepng($this->image, $filename);
}
if ($permissions != null) {
chmod($filename, $permissions);
}
}
开发者ID:Tripbull,项目名称:newrepo,代码行数:33,代码来源:class.resizephoto.php
示例15: generateImage
function generateImage($certiImage, $posXString, $posYString, $posX2String, $posY2String, $valueString)
{
$certiPath = dirname(__FILE__);
$certiImage = imagecreatefromjpeg($certiPath . '/certi_images/' . $certiImage);
$color = imagecolorallocate($certiImage, 0, 0, 0);
//black
// $whiteBackground = imagecolorallocate($background, 255, 255, 255);
// $imagefill($certiImage,0,0,$whiteBackground);
$rotatedImage = imagerotate($certiImage, 90, $color);
//rotate certificate
$font = $certiPath . '/fonts/odstemplik.otf';
$posXArray = explode("::", $posXString);
$posYArray = explode("::", $posYString);
$posX2Array = explode("::", $posX2String);
$posY2Array = explode("::", $posY2String);
$valuesArray = explode("::", $valueString);
// error_log(print_r($valuesArray));
for ($i = 0; $i < sizeof($valuesArray); $i++) {
$lineWidth = $posYArray[$i] - $posY2Array[$i];
$font_size = 90;
do {
$p = imagettfbbox($font_size, 0, $font, $valuesArray[$i]);
$textWidth = $p[2] - $p[0];
$font_size--;
// error_log($textWidth);
} while ($textWidth >= $lineWidth);
$y = ($lineWidth - $textWidth) / 2;
imagettftext($rotatedImage, $font_size, 90, $posXArray[$i], $posYArray[$i] - $y, $color, $font, $valuesArray[$i]);
}
ob_start();
imagejpeg($rotatedImage);
$actual_image = base64_encode(ob_get_contents());
ob_end_clean();
return "data:image/png;base64," . $actual_image;
}
开发者ID:ksb1712,项目名称:pragyan,代码行数:35,代码来源:events_certi_image2.php
示例16: createOrientedImage
private function createOrientedImage($exif)
{
$image = imagecreatefromstring($this->FileBin->bin);
switch ($exif) {
// rotate 180 degrees
case 3:
$image = imagerotate($image, 180, 0);
break;
// rotate 90 degrees
// rotate 90 degrees
case 6:
$imagewidth = imagesy($image);
$imageheight = imagesx($image);
$image = imagerotate($image, -90, 0);
imagecopyresampled($image, $image, 0, 0, (imagesx($image) - $imagewidth) / 2, (imagesy($image) - $imageheight) / 2, $imagewidth, $imageheight, $imagewidth, $imageheight);
break;
// rotate 270 degrees
// rotate 270 degrees
case 8:
$imagewidth = imagesy($image);
$imageheight = imagesx($image);
$image = imagerotate($image, 90, 0);
imagecopyresampled($image, $image, 0, 0, (imagesx($image) - $imagewidth) / 2, (imagesy($image) - $imageheight) / 2, $imagewidth, $imageheight, $imagewidth, $imageheight);
break;
default:
break;
}
ob_start();
imagejpeg($image);
$ei = ob_get_contents();
ob_end_clean();
return $ei;
}
开发者ID:te-koyama,项目名称:openpne,代码行数:33,代码来源:File.class.php
示例17: getImage
private function getImage()
{
$image = imagecreatefromstring(file_get_contents($this->file['tmp_name']));
if ($this->currentExtension == 'jpg' || $this->currentExtension == 'jpeg') {
$exif = exif_read_data($this->file['tmp_name']);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$image = imagerotate($image, 90, 0);
break;
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
}
}
}
// Get new sizes
$width = imagesx($image);
$height = imagesy($image);
//list($width, $height) = getimagesize($this->file['tmp_name']);
list($newWidth, $newHeight) = $this->getScaledDimArray($image, 800);
// Load
$resizeImage = imagecreatetruecolor($newWidth, $newHeight);
// Resize
imagecopyresized($resizeImage, $image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
return $resizeImage;
}
开发者ID:ambujaacool,项目名称:MyApp,代码行数:30,代码来源:ImageUpload.php
示例18: fixImageOrientation
function fixImageOrientation($path)
{
$info = getimagesize($path);
if ($info['mime'] != "image/jpeg") {
return;
}
$exif = exif_read_data($path);
if (exif_imagetype($path) != IMAGETYPE_JPEG) {
return;
}
if (empty($exif['Orientation'])) {
return;
}
$image = imagecreatefromjpeg($path);
switch ($exif['Orientation']) {
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
case 8:
$image = imagerotate($image, 90, 0);
break;
}
imagejpeg($image, $path);
}
开发者ID:krombox,项目名称:motion,代码行数:27,代码来源:ImageTypeExtension.php
示例19: run
public function run($file)
{
$progressive = isset($this->settings['field_settings']['progressive_jpeg']) === TRUE && $this->settings['field_settings']['progressive_jpeg'] == 'yes' ? TRUE : FALSE;
$this->size = getimagesize($file);
$width = $this->size[0];
$height = $this->size[1];
if (isset($this->settings['only_if']) === TRUE) {
// Do we need to rotate?
if ($this->settings['only_if'] == 'width_bigger' && $width < $height) {
return TRUE;
} elseif ($this->settings['only_if'] == 'height_bigger' && $height < $width) {
return TRUE;
}
}
switch ($this->size[2]) {
case 1:
if (imagetypes() & IMG_GIF) {
$this->im = imagecreatefromgif($file);
} else {
return 'No GIF Support!';
}
break;
case 2:
if (imagetypes() & IMG_JPG) {
$this->im = imagecreatefromjpeg($file);
} else {
return 'No JPG Support!';
}
break;
case 3:
if (imagetypes() & IMG_PNG) {
$this->im = imagecreatefrompng($file);
} else {
return 'No PNG Support!';
}
break;
default:
return 'File Type??';
}
$this->settings['background_color'];
$this->settings['degrees'];
$this->im = imagerotate($this->im, 360 - $this->settings['degrees'], hexdec($this->settings['background_color']));
switch ($this->size[2]) {
case 1:
imagegif($this->im, $file);
break;
case 2:
if ($progressive === TRUE) {
@imageinterlace($this->im, 1);
}
imagejpeg($this->im, $file, 100);
break;
case 3:
imagepng($this->im, $file);
break;
}
imagedestroy($this->im);
return TRUE;
}
开发者ID:ayuinc,项目名称:laboratoria-v2,代码行数:59,代码来源:action.rotate.php
示例20: rotate
public function rotate($degrees)
{
if (!$this->is_valid()) {
return FALSE;
}
$this->image = imagerotate($this->image, $degrees, 0);
$this->setDimensions();
}
开发者ID:Mauru,项目名称:red,代码行数:8,代码来源:photo_gd.php
注:本文中的imagerotate函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论