本文整理汇总了PHP中imageflip函数的典型用法代码示例。如果您正苦于以下问题:PHP imageflip函数的具体用法?PHP imageflip怎么用?PHP imageflip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imageflip函数的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: imagerotate
/**
* Substitute for GD imagerotate
*
* @param image $imgSrc
* @param int $angle
* @param int $bgd_colour
* @return image
*/
function imagerotate($imgSrc, $angle, $bgd_colour)
{
// ensuring we got really RightAngle (if not we choose the closest one)
$angle = min((int) (($angle + 45) / 90) * 90, 270);
// no need to fight
if ($angle == 0) {
return $imgSrc;
}
// dimenstion of source image
$srcX = imagesx($imgSrc);
$srcY = imagesy($imgSrc);
switch ($angle) {
case 90:
$imgDest = imagecreatetruecolor($srcY, $srcX);
for ($x = 0; $x < $srcX; $x++) {
for ($y = 0; $y < $srcY; $y++) {
imagecopy($imgDest, $imgSrc, $srcY - $y - 1, $x, $x, $y, 1, 1);
}
}
break;
case 180:
$imgDest = imageflip($imgSrc, IMAGE_FLIP_BOTH);
break;
case 270:
$imgDest = imagecreatetruecolor($srcY, $srcX);
for ($x = 0; $x < $srcX; $x++) {
for ($y = 0; $y < $srcY; $y++) {
imagecopy($imgDest, $imgSrc, $y, $srcX - $x - 1, $x, $y, 1, 1);
}
}
break;
}
return $imgDest;
}
开发者ID:hatone,项目名称:zenphoto-1.4.1.4,代码行数:42,代码来源:_functions_GD.php
示例3: Mirror
public static function Mirror($image, $outtype = "png", $raw = false, $vertical = false)
{
if (!$raw) {
list($size["x"], $size["y"]) = getimagesize($image);
} else {
list($size["x"], $size["y"]) = getimagesizefromstring($image);
}
$data = RandImg::loadImage($image, $raw);
imageflip($data, $vertical ? IMG_FLIP_VERTICAL : IMG_FLIP_HORIZONTAL);
return RandImg::makeImageString($data, $outtype);
}
开发者ID:AlexusBlack,项目名称:image-randomizer,代码行数:11,代码来源:RandImg.php
示例4: applyRotation
protected function applyRotation($image, $rotation)
{
if ($rotation & self::PATTERN_FLIP_H) {
imageflip($image, IMG_FLIP_HORIZONTAL);
}
if ($rotation & self::PATTERN_FLIP_V) {
imageflip($image, IMG_FLIP_VERTICAL);
}
if ($rotation & self::PATTERN_ANGLE_MASK) {
$image = imagerotate($image, ($rotation & self::PATTERN_ANGLE_MASK) * 90, $this->bgColorValue);
}
return $image;
}
开发者ID:ranvis,项目名称:identicon,代码行数:13,代码来源:TileBase.php
示例5: renderBody
public function renderBody($skin, $size, $hat = false)
{
$bodyWidth = (int) floor($size / 2);
$bodyHeight = (int) floor($bodyWidth * 1.5);
$armWidth = (int) floor($size / 4);
$width = (int) $bodyWidth * 2;
$height = (int) $width * 2;
$skin = base64_decode($skin);
$imgBody = imagecreatetruecolor($width, $height);
$imgSkin = imagecreatefromstring($skin);
$transparency = imagecolorat($imgSkin, 0, 0);
$alphaRed = $transparency >> 16 & 0xff;
$alphaGreen = $transparency >> 8 & 0xff;
$alphaBlue = $transparency & 0xff;
// Make body transparent
imagesavealpha($imgBody, true);
$transparent = imagecolorallocatealpha($imgBody, 0, 0, 0, 127);
imagefill($imgBody, 0, 0, $transparent);
// Head (and hat, of course)
imagecopyresized($imgBody, $imgSkin, $armWidth, 0, 8, 8, $bodyWidth, $bodyWidth, 8, 8);
if ($hat) {
$imgHat = imagecreatetruecolor($bodyWidth, $bodyWidth);
imagecolortransparent($imgHat, $transparency);
imagecopy($imgBody, $imgHat, 0, 0, $armWidth, 0, $bodyWidth, $bodyWidth);
imagecopyresized($imgHat, $imgSkin, $armWidth, 0, 40, 8, $bodyWidth, $bodyWidth, 8, 8);
/*$rgb = imagecolorallocatealpha( $imgHat, 0, 0, 0, 127 );
imagefill( $imgHat, 0, 0, $rgb );*/
}
// Body
imagecopyresized($imgBody, $imgSkin, $armWidth, $bodyWidth, 20, 20, $bodyWidth, $bodyHeight, 8, 12);
// Arms
imagecopyresized($imgBody, $imgSkin, $armWidth + $bodyWidth, $bodyWidth, 44, 20, $armWidth, $bodyHeight, 4, 12);
imagecopyresized($imgBody, $imgSkin, 0, $bodyWidth, 44, 20, $armWidth, $bodyHeight, 4, 12);
// Legs
/**
* X: 4
* Y: 20
*/
imagecopyresized($imgBody, $imgSkin, $armWidth, $bodyWidth + $bodyHeight, 4, 20, $armWidth, $bodyHeight, 4, 12);
$imgLeftLeg = imagecreatetruecolor($armWidth, $bodyHeight);
imagecopyresized($imgLeftLeg, $imgSkin, 0, 0, 4, 20, $armWidth, $bodyHeight, 4, 12);
imageflip($imgLeftLeg, IMG_FLIP_HORIZONTAL);
imagecopy($imgBody, $imgLeftLeg, $bodyWidth, $bodyWidth + $bodyHeight, 0, 0, $armWidth, $bodyHeight);
imagedestroy($imgLeftLeg);
header('Content-type: image/png');
imagepng($imgBody);
imagedestroy($imgSkin);
imagedestroy($imgBody);
}
开发者ID:nickdodd25,项目名称:mcavatars,代码行数:49,代码来源:Render.php
示例6: flip
/**
* @inheritdoc
*/
public function flip($flipVertical, $flipHorizontal)
{
if (!$flipVertical && !$flipHorizontal) {
return $this;
}
if (function_exists('imageflip')) {
if ($flipVertical && $flipHorizontal) {
$flipMode = \IMG_FLIP_BOTH;
} else {
if ($flipVertical && !$flipHorizontal) {
$flipMode = \IMG_FLIP_VERTICAL;
} else {
if (!$flipVertical && $flipHorizontal) {
$flipMode = \IMG_FLIP_HORIZONTAL;
}
}
}
imageflip($this->resource, $flipMode);
} else {
$width = $this->width();
$height = $this->height();
$src_x = 0;
$src_y = 0;
$src_width = $width;
$src_height = $height;
if ($flipVertical) {
$src_y = $height - 1;
$src_height = -$height;
}
if ($flipHorizontal) {
$src_x = $width - 1;
$src_width = -$width;
}
$imgdest = imagecreatetruecolor($width, $height);
imagealphablending($imgdest, false);
imagesavealpha($imgdest, true);
if (imagecopyresampled($imgdest, $this->resource, 0, 0, $src_x, $src_y, $width, $height, $src_width, $src_height)) {
imagedestroy($this->resource);
$this->resource = $imgdest;
}
}
return $this;
}
开发者ID:clee03,项目名称:metal,代码行数:46,代码来源:GD.php
示例7: rotate
/**
* rotate image
* @param integer|string $degree degree of rotation. (0, 90, 180, 270). for php < 5.5, you cannot use flip hor, vrt, horvrt
* @return boolean
*/
public function rotate($degree = '90')
{
// if constructor failed to load.
if (!$this->checkConstructorLoad()) {
return false;
}
// check degree
$allowed_degree = array(0, 90, 180, 270, 'hor', 'vrt', 'horvrt');
if (!in_array($degree, $allowed_degree)) {
$degree = 90;
}
if (!is_int($degree) && $degree != 'hor' && $degree != 'vrt' && $degree != 'horvrt') {
$degree = (int) $degree;
}
unset($allowed_degree);
// if image content not set, set it up (this case just call crop without resize).
if ($this->new_img_content == null) {
$result = $this->setImageContent();
if ($result === false) {
$this->status = false;
$this->status_msg = 'Failed to set image content.';
return false;
}
$new_img_content = $this->new_img_content;
unset($result);
} else {
$new_img_content = $this->new_img_object;
}
// rotate.
if (is_int($degree)) {
// rotate by degrees number
switch ($this->original_img_ext) {
case '1':
// gif
// gif
case '2':
// jpg
$rotate = imagerotate($new_img_content, $degree, 0);
break;
case '3':
// png
$rotate = imagerotate($new_img_content, $degree, imageColorAllocateAlpha($new_img_content, 0, 0, 0, 127));
imagealphablending($rotate, false);
imagesavealpha($rotate, true);
break;
default:
// not allowed image type.
$this->status = false;
$this->status_msg = 'Unable to rotate this type of image.';
return false;
break;
}
$this->new_img_object = $rotate;
$this->new_img_height = imagesy($rotate);
$this->new_img_width = imagesx($rotate);
// re-set original image height & width. because image was rotate
$this->original_img_height = $this->new_img_height;
$this->original_img_width = $this->new_img_width;
} else {
// if php version lower than 5.5
if (phpversion() < 5.5) {
$this->status = false;
$this->status_msg = 'Unable to flip image using PHP older than 5.5.';
return false;
}
if ($degree == 'hor') {
$mode = IMG_FLIP_HORIZONTAL;
} elseif ($degree == 'vrt') {
$mode = IMG_FLIP_VERTICAL;
} else {
$mode = IMG_FLIP_BOTH;
}
// flip image.
imageflip($new_img_content, $mode);
unset($mode);
$this->new_img_object = $new_img_content;
$this->new_img_height = imagesy($new_img_content);
$this->new_img_width = imagesx($new_img_content);
// re-set original image height & width. because image was rotate
$this->original_img_height = $this->new_img_height;
$this->original_img_width = $this->new_img_width;
}
return true;
}
开发者ID:rundiz,项目名称:fuel-start,代码行数:89,代码来源:Vimage.php
示例8: getFlippedGdResource
/**
* Flip the image
* @param resource $srcResource the image resource
* @param int $mode flip mode
* @return resource the flipped resource
*/
public function getFlippedGdResource($srcResource, $mode)
{
imageflip($srcResource, $mode);
return $srcResource;
}
开发者ID:nodir-y,项目名称:imagecraft,代码行数:11,代码来源:ResourceHelper.php
示例9: print_thumbnail
//.........这里部分代码省略.........
$width2 = $width;
$width = $height;
$height = $width2;
}
//Now lets resize it
//First lets create a new image handler which will be the thumbnailed image
$thumbnail = imagecreatetruecolor($width, $height);
if (!$thumbnail) {
return $this->set_error("Method print_thumbnail: A thumbnail image '{$image}' could not be created");
}
/* Image Format Special Handlinng */
//GIF truecolour to palette - preserve transparency
if ($format == 1) {
imagetruecolortopalette($handle, true, 256);
}
//PNG Alpha Channel saving
if ($format == 3) {
//Set to save alpha channel info in source and destination
imagealphablending($handle, false);
imagesavealpha($handle, true);
imagealphablending($thumbnail, false);
imagesavealpha($thumbnail, true);
}
//Resize it
if (!$this->fastimagecopyresampled($thumbnail, $handle, 0, 0, 0, 0, $width, $height, ImageSX($handle), ImageSY($handle), $this->thumb_quality)) {
return $this->set_error("Method print_thumbnail: Failed resizing image '{$image}'.");
}
// Rotate if JPEG and Exif Information is available
$orientation = $this->exiforientation($image, true);
if ($this->rotationsupported($orientation)) {
switch ($orientation) {
case 2:
// mirror horizontal
@imageflip($thumbnail, IMG_FLIP_HORIZONTAL);
break;
case 3:
// rotate 180
$thumbnail = @imagerotate($thumbnail, 180, imagecolorallocate($thumbnail, 255, 255, 255));
break;
case 4:
// mirror vertical
@imageflip($thumbnail, IMG_FLIP_VERTICAL);
break;
case 5:
// mirror horizontal, 90 rotate left
@imageflip($thumbnail, IMG_FLIP_HORIZONTAL);
$thumbnail = @imagerotate($thumbnail, 90, imagecolorallocate($thumbnail, 255, 255, 255));
break;
case 6:
// 90 rotate right
$thumbnail = @imagerotate($thumbnail, -90, imagecolorallocate($thumbnail, 255, 255, 255));
break;
case 7:
// mirror horizontal, 90 rotate right
@imageflip($thumbnail, IMG_FLIP_HORIZONTAL);
$thumbnail = @imagerotate($thumbnail, -90, imagecolorallocate($thumbnail, 255, 255, 255));
break;
case 8:
// 90 rotate left
$thumbnail = @imagerotate($thumbnail, 90, imagecolorallocate($thumbnail, 255, 255, 255));
break;
}
}
//Cache it
if ($this->is_cacheable()) {
switch ($format) {
开发者ID:rbrdevs,项目名称:pydio-core,代码行数:67,代码来源:PThumb.lib.php
示例10: imageCreateJpegfromExif
public function imageCreateJpegfromExif($filename)
{
$img = imagecreatefromjpeg($filename);
$exif = exif_read_data($filename);
if (!$exif || !isset($exif['Orientation'])) {
return $img;
}
$orientation = $exif['Orientation'];
if ($orientation === 6 || $orientation === 5) {
$img = imagerotate($img, 270, null);
} else {
if ($orientation === 3 || $orientation === 4) {
$img = imagerotate($img, 180, null);
} else {
if ($orientation === 8 || $orientation === 7) {
$img = imagerotate($img, 90, null);
}
}
}
if ($orientation === 5 || $orientation === 4 || $orientation === 7) {
imageflip($img, IMG_FLIP_HORIZONTAL);
}
return $img;
}
开发者ID:saschanos,项目名称:php-image-resize,代码行数:24,代码来源:ImageResize.php
示例11: flipImg
function flipImg($imgPathName)
{
$filename = $imgPathName;
#$this->CI->dir_lib->getImgRdir().$this->lastLoadImgName;
preg_match("#\\.([a-z]{3,4})\$#", $filename, $arr);
if (isset($arr[1]) && !empty($arr[1])) {
switch ($arr[1]) {
case 'png':
$header = 'image/png';
$createImgFunc = '$im = imagecreatefrompng($filename);';
$outputImgFunc = 'imagepng($im,$filename);';
break;
case 'jpg':
$header = 'image/jpeg';
$createImgFunc = '$im = imagecreatefromjpeg($filename);';
$outputImgFunc = 'imagejpeg($im,$filename,100);';
break;
case 'jpeg':
$header = 'image/jpeg';
$createImgFunc = '$im = imagecreatefromjpeg($filename);';
$outputImgFunc = 'imagejpeg($im,$filename,100);';
break;
default:
$header = false;
}
}
if (!$header) {
return false;
}
// Load
eval($createImgFunc);
// Flip it horizontally
imageflip($im, IMG_FLIP_HORIZONTAL);
// Output
eval($outputImgFunc);
imagedestroy($im);
}
开发者ID:skybee,项目名称:france,代码行数:37,代码来源:Parse_lib.php
示例12: rotate
/**
* {@inheritDoc}
*/
public function rotate($degree = 90)
{
if (false === $this->isClassSetup()) {
return false;
}
// check degree
$allowed_flip = array('hor', 'vrt', 'horvrt');
if (is_numeric($degree)) {
$degree = intval($degree);
} elseif (!is_numeric($degree) && !in_array($degree, $allowed_flip)) {
$degree = 90;
}
unset($allowed_flip);
// setup source image object
if (false === $this->setupSourceImageObject()) {
return false;
}
// check previous step contain errors?
if ($this->isPreviousError() === true) {
return false;
}
// begins rotate.
if (is_int($degree)) {
// rotate by degree
switch ($this->source_image_type) {
case '1':
// gif
// set source image width and height
$source_image_width = imagesx($this->source_image_object);
$source_image_height = imagesy($this->source_image_object);
$this->destination_image_object = imagecreatetruecolor($source_image_width, $source_image_height);
$transwhite = imagecolorallocatealpha($this->destination_image_object, 255, 255, 255, 127);
imagefill($this->destination_image_object, 0, 0, $transwhite);
imagecolortransparent($this->destination_image_object, $transwhite);
imagecopy($this->destination_image_object, $this->source_image_object, 0, 0, 0, 0, $source_image_width, $source_image_height);
$this->destination_image_object = imagerotate($this->destination_image_object, $degree, $transwhite);
unset($source_image_height, $source_image_width, $transwhite);
break;
case '2':
// jpg
$white = imagecolorallocate($this->source_image_object, 255, 255, 255);
$this->destination_image_object = imagerotate($this->source_image_object, $degree, $white);
unset($white);
break;
case '3':
// png
$transwhite = imageColorAllocateAlpha($this->source_image_object, 0, 0, 0, 127);
$this->destination_image_object = imagerotate($this->source_image_object, $degree, $transwhite);
imagealphablending($this->destination_image_object, false);
imagesavealpha($this->destination_image_object, true);
unset($transwhite);
break;
default:
$this->status = false;
$this->status_msg = 'Unable to rotate this kind of image.';
return false;
}
$this->destination_image_height = imagesy($this->destination_image_object);
$this->destination_image_width = imagesx($this->destination_image_object);
$this->source_image_height = $this->destination_image_height;
$this->source_image_width = $this->destination_image_width;
} else {
// flip image
if (version_compare(phpversion(), '5.5', '<')) {
$this->status = false;
$this->status_msg = 'Unable to flip image using PHP older than 5.5.';
return false;
}
if ($degree == 'hor') {
$mode = IMG_FLIP_HORIZONTAL;
} elseif ($degree == 'vrt') {
$mode = IMG_FLIP_VERTICAL;
} else {
$mode = IMG_FLIP_BOTH;
}
// flip image.
imageflip($this->source_image_object, $mode);
unset($mode);
$this->destination_image_object = $this->source_image_object;
$this->destination_image_height = imagesy($this->source_image_object);
$this->destination_image_width = imagesx($this->source_image_object);
$this->source_image_height = $this->destination_image_height;
$this->source_image_width = $this->destination_image_width;
}
// clear
if (get_resource_type($this->source_image_object) === 'gd') {
if ($this->source_image_object != $this->destination_image_object) {
imagedestroy($this->source_image_object);
}
$this->source_image_object = null;
}
if (!$this->isPreviousError()) {
$this->status = true;
$this->status_msg = null;
}
return true;
}
开发者ID:rundiz,项目名称:image,代码行数:100,代码来源:Gd.php
示例13: __image_flip
function __image_flip($img, $mode)
{
if (function_exists("imageflip")) {
return imageflip($img, $mode);
}
$width = imagesx($img);
$height = imagesy($img);
$src_x = 0;
$src_y = 0;
$src_width = $width;
$src_height = $height;
switch ($mode) {
case FLIP_HORIZONTAL:
$src_x = $width - 1;
$src_width = -$width;
break;
case FLIP_VERTICAL:
$src_y = $height - 1;
$src_height = -$height;
break;
case FLIP_BOTH:
$src_x = $width - 1;
$src_y = $height - 1;
$src_width = -$width;
$src_height = -$height;
break;
default:
return $img;
}
$img_new = imagecreatetruecolor($width, $height);
return imagecopyresampled($img_new, $img, 0, 0, $src_x, $src_y, $width, $height, $src_width, $src_height) ? $img_new : $img;
}
开发者ID:Kunnapat,项目名称:chowtime,代码行数:32,代码来源:imager.php
示例14: draw
/**
* draw icon to internal buffer
* @param string $hash
* @return $this
*/
public function draw($hash)
{
$index = 0;
$tiles = $this->tiles;
$tileSize = $this->tileSize;
$tile = $this->tile;
$tile->allocate($tileSize);
$br = $tileSize * ($tiles - 1);
$offsets = array(array(0, 0, 0, 1, 1, 0), array($br, 0, -1, 0, 0, 1), array($br, $br, 0, -1, -1, 0), array(0, $br, 1, 0, 0, -1), array($br, 0, 0, 1, -1, 0), array($br, $br, -1, 0, 0, -1), array(0, $br, 0, -1, 1, 0), array(0, 0, 1, 0, 0, 1));
if (!$this->image) {
$this->image = $image = imagecreatetruecolor($tileSize * $tiles, $tileSize * $tiles);
$this->white = imagecolorallocate($image, 255, 255, 255);
}
$image = $this->image;
$white = $this->white;
$xEnd = $tiles + 1 >> 1;
$xMid = $xEnd + 1 >> 1;
$center = $tiles & 1 ? $tiles >> 1 : -1;
$numColors = $this->colors;
assert('$this->getMinimumHashLength() <= strlen($hash)');
$colors = array();
for ($i = 0; $i < $numColors; $i++) {
$r = hexdec(substr($hash, $index, 2));
$index += 2;
$g = hexdec(substr($hash, $index, 2));
$index += 2;
$b = hexdec(substr($hash, $index, 2));
$index += 2;
$colors[] = $tile->getColor($r, $g, $b);
}
$baseColor = hexdec($hash[$index++]);
$colorPattern = hexdec($hash[$index++]);
$type = hexdec($hash[$index++]);
for ($x = 0; $x < $xEnd; $x++) {
$xOffsets = $offsets;
for ($y = 0; $y <= $x; $y++) {
$color = $baseColor;
if ($colorPattern & 1) {
$color++;
}
if ($colorPattern & 2) {
$color += $x;
}
if ($colorPattern & 4) {
$color += $y;
}
if ($colorPattern & 8) {
$color += $x <= $xMid;
}
$type += hexdec($hash[$index++]);
$tileImage = $tile->draw($type, $colors[$color % $numColors]);
for ($i = 0; $i < 8; $i++) {
if ($i == 4 && ($y == $x || $x == 0)) {
break;
}
$offset = $xOffsets[$i];
if ($i < 4 || $x != $center) {
if ($i == 4) {
imageflip($tileImage, IMG_FLIP_HORIZONTAL);
}
imagecopy($image, $tileImage, $offset[0], $offset[1], 0, 0, $tileSize, $tileSize);
if ($x == $center && $y == $center) {
break;
}
if ($i != 7) {
$tileImage = imagerotate($tileImage, 270, $white);
}
}
$xOffsets[$i][0] += $offset[2] * $tileSize;
$xOffsets[$i][1] += $offset[3] * $tileSize;
}
}
for ($i = 0; $i < 8; $i++) {
$offsets[$i][0] += $offsets[$i][4] * $tileSize;
$offsets[$i][1] += $offsets[$i][5] * $tileSize;
}
}
return $this;
}
开发者ID:ranvis,项目名称:identicon,代码行数:84,代码来源:Identicon.php
示例15: wppa_orientate_image_file
function wppa_orientate_image_file($file, $ori)
{
// Validate args
if (!is_file($file)) {
wppa_log('Err', 'File not found (wppa_orientate_image_file())');
return false;
}
if (!wppa_is_int($ori) || $ori < '2' || $ori > '8') {
wppa_log('Err', 'Bad arg $ori:' . $ori . ' (wppa_orientate_image_file())');
return false;
}
// Load image
$source = wppa_imagecreatefromjpeg($file);
if (!$source) {
wppa_log('Err', 'Could not create memoryimage from jpg file ' . $file);
return false;
}
// Perform operation
switch ($ori) {
case '2':
$orientate = $source;
imageflip($orientate, IMG_FLIP_HORIZONTAL);
break;
case '3':
$orientate = imagerotate($source, 180, 0);
break;
case '4':
$orientate = $source;
imageflip($orientate, IMG_FLIP_VERTICAL);
break;
case '5':
$orientate = imagerotate($source, 270, 0);
imageflip($orientate, IMG_FLIP_HORIZONTAL);
break;
case '6':
$orientate = imagerotate($source, 270, 0);
break;
case '7':
$orientate = imagerotate($source, 90, 0);
imageflip($orientate, IMG_FLIP_HORIZONTAL);
break;
case '8':
$orientate = imagerotate($source, 90, 0);
break;
}
// Output
imagejpeg($orientate, $file, wppa_opt('jpeg_quality'));
// Accessable
wppa_chmod($file);
// Optimized
wppa_optimize_image_file($file);
// Free the memory
imagedestroy($source);
@imagedestroy($orientate);
// Done
return true;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:57,代码来源:wppa-photo-files.php
示例16: resize
/**
* Resizes image.
* @param mixed width in pixels or percent
* @param mixed height in pixels or percent
* @param int flags
* @return self
*/
public function resize($width, $height, $flags = self::FIT)
{
if ($flags & self::EXACT) {
return $this->resize($width, $height, self::FILL)->crop('50%', '50%', $width, $height);
}
list($newWidth, $newHeight) = static::calculateSize($this->getWidth(), $this->getHeight(), $width, $height, $flags);
if ($newWidth !== $this->getWidth() || $newHeight !== $this->getHeight()) {
// resize
$newImage = static::fromBlank($newWidth, $newHeight, self::RGB(0, 0, 0, 127))->getImageResource();
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $this->getWidth(), $this->getHeight());
$this->image = $newImage;
}
if ($width < 0 || $height < 0) {
imageflip($this->image, $width < 0 ? $height < 0 ? IMG_FLIP_BOTH : IMG_FLIP_HORIZONTAL : IMG_FLIP_VERTICAL);
}
return $this;
}
开发者ID:radekdostal,项目名称:utils,代码行数:24,代码来源:Image.php
示例17: output
/**
* Imprime um frame da animação do personagem
* @param $action_index animação desejada
* @param $frame_index frame da animação
*/
public function output($action_index, $frame_index, $filename = "")
{
$center_x = $this->width / 2;
$center_y = $this->height / 4 * 3;
$img = imagecreatetruecolor($this->width, $this->height);
// Cor que vai ser usada para a transparencia
$pink = imagecolorallocate($img, 255, 255, 255);
// Deixa toda a imagem transparente
imagefill($img, 0, 0, $pink);
imagecolortransparent($img, $pink);
//Pega o frame do corpo
$body = $this->body->getActionList()->getAction($action_index)->getFrame($frame_index);
//e os sprites que compõem ele
$sprites = $body->getSprites();
// desenha o corpo
foreach ($sprites as $s) {
// caso o sprite seja invalido pula ele
if ($s->getIndex() < 0) {
continue;
}
//cria a imagem
$tmp_img = $this->body->getSpriteList()->getSprite($s->getIndex())->createImage();
//espelha a imagem se necessario
if ($s->getMirror()) {
imageflip($tmp_img, IMAGE_FLIP_HORIZONTAL);
}
imagerotate($tmp_img, $s->getRotation(), $pink);
// calcula a largura e altura
$width = $s->getWidth() ? $s->getWidth() : imagesx($tmp_img);
$height = $s->getHeight() ? $s->getHeight() : imagesy($tmp_img);
$width *= $s->getScaleX();
$height *= $s->getScaleY();
//desenha o sprite
imagecopyresized($img, $tmp_img, $center_x - $width / 2 + $s->getX(), $center_y - $height / 2 + $s->getY(), 0, 0, $width, $height, imagesx($tmp_img), imagesy($tmp_img));
imagedestroy($tmp_img);
}
//desenha todas as outras partes que compõem o personagem
foreach ($this->parts as $part) {
$frame = $part->getActionList()->getAction($action_index)->getFrame($frame_index);
$sprites = $frame->getSprites();
foreach ($sprites as $s) {
if ($s->getIndex() < 0) {
continue;
}
$tmp_img = $part->getSpriteList()->getSprite($s->getIndex())->createImage();
if ($s->getMirror()) {
imageflip($tmp_img, IMAGE_FLIP_HORIZONTAL);
}
imagerotate($tmp_img, $s->getRotation(), $pink);
//imagefilter($tmp_img, IMG_FILTER_COLORIZE, 255, 0, 0, 255);
$width = $s->getWidth() ? $s->getWidth() : imagesx($tmp_img);
$height = $s->getHeight() ? $s->getHeight() : imagesy($tmp_img);
$width *= $s->getScaleX();
$height *= $s->getScaleY();
imagecopyresized($img, $tmp_img, $center_x + ($body->getAttachPoint(0)->getX() - $frame->getAttachPoint(0)->getX() + $s->getX()) - $width / 2, $center_y + ($body->getAttachPoint(0)->getY() - $frame->getAttachPoint(0)->getY() + $s->getY()) - $height / 2, 0, 0, $width, $height, imagesx($tmp_img), imagesy($tmp_img));
imagedestroy($tmp_img);
}
}
header("Content-Type: image/gif");
imagegif($img);
imagedestroy($img);
}
开发者ID:puring0815,项目名称:OpenKore,代码行数:67,代码来源:Character.php
示例18: imagecreatetruecolor
<?php
$im = imagecreatetruecolor(99, 99);
imagesetpixel($im, 0, 0, 0xff);
imagesetpixel($im, 0, 98, 0xff00);
imagesetpixel($im, 98, 0, 0xff0000);
imagesetpixel($im, 98, 98, 0xff);
imageflip($im, IMG_FLIP_HORIZONTAL);
imageflip($im, IMG_FLIP_VERTICAL);
imageflip($im, IMG_FLIP_BOTH);
var_dump(dechex(imagecolorat($im, 0, 0)));
var_dump(dechex(imagecolorat($im, 0, 98)));
var_dump(dechex(imagecolorat($im, 98, 0)));
var_dump(dechex(imagecolorat($im, 98, 98)));
?>
开发者ID:badlamer,项目名称:hhvm,代码行数:15,代码来源:imageflip.php
示例19: flip_horizontal
function flip_horizontal(&$imgsrc)
{
// PHP5.5以上であればimageflipがあるので使う
if (function_exists('imageflip')) {
imageflip($imgsrc, IMG_FLIP_HORIZONTAL);
return;
}
$x = imagesx($imgsrc);
$y = imagesy($imgsrc);
$flip = imagecreatetruecolor($x, $y);
if (imagecopyresampled($flip, $imgsrc, 0, 0, $x - 1, 0, $x, $y, 0 - $x, $y)) {
$imgsrc = $flip;
}
}
开发者ID:sus-happy,项目名称:Fegg_Tool_Trim,代码行数:14,代码来源:Trim.php
示例20: gd_imageflip
protected function gd_imageflip($image, $mode)
{
if (function_exists('imageflip')) {
return imageflip($image, $mode);
}
$new_width = $src_width = imagesx($image);
$new_height = $src_height = imagesy($image);
$new_img = imagecreatetruecolor($new_width, $new_height);
$src_x = 0;
$src_y = 0;
switch ($mode) {
case '1':
// flip on the horizontal axis
$src_y = $new_height - 1;
$src_height = -$new_height;
break;
case '2':
// flip on the vertical axis
$src_x = $new_width - 1;
$src_width = -$new_width;
break;
case '3':
// flip on both axes
$src_y = $new_height - 1;
$src_height = -$new_height;
$src_x = $new_width - 1;
$src_width = -$new_width;
break;
default:
return $image;
}
imagecopyresampled($new_img, $image, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_width, $src_height);
return $new_img;
}
开发者ID:cruni505,项目名称:prestomed,代码行数:34,代码来源:UploadIncentivoImg.php
注:本文中的imageflip函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论