English 中文(简体)
• 如何将图像的横向部分投向公用钥匙,GD
原标题:How to flip part of an image horizontal with PHP GD
  • 时间:2011-11-22 19:39:45
  •  标签:
  • php
  • image
  • gd

我正在用另一个图像制造一个部分的形象。 我只使用“部分”的图像。 一些部分需要横向缩减。

例如,这一部分:

imagecopy($output, $input, 0,8, 44,20, 4,12);

如何将这一部分横向排除在外?

我已尝试这样做:

imagecopy($output, $input, (0 - 1),8, 44,20, 4,12);

但它并不奏效。

我寻找了年龄,但找不到任何能够奏效的东西。

我的描述就是这样:

$input = imagecreatefrompng($image_file);
$output = imagecreatetruecolor(50, 40);

imagecopy($output, $input, 4,8, 20,20, 8,14);
imagecopy($output, $input, 12,8, 44,20, 4,14);
imagecopy($output, $input, 4,20, 4,20, 4,14);
imagecopy($output, $input, 8,28, 4,20, 4,14);
imagecopy($output, $input, 32,8, 52,20, 4,14);
imagecopy($output, $input, 24,20, 12,20, 4,14);
imagecopy($output, $input, 28,28, 12,20, 4,14); 
imagecopy($output, $input, 4,0, 40,8, 8,9);
imagecopy($output, $input, 24,0, 56,8, 8,9);


header( Content-Type: image/png );

imagepng($output);

imagedestroy($output);
imagedestroy($input);
最佳回答

几年后,我要谈谈答案......

变化:

imagecopy($output, $input, 8, 20, 4, 20, 4, 12)

:

imagecopyresampled($output, $input, 8, 20, (8 - 1), 20, 4, 12, 0 - 4, 12);

它将lip平图像的一部分。

问题回答

。 创办人:

//**************************************
// Name: Flip Image with GD
// Description:These are two easy to use functions that will flip an image, either horizontally or vertically. Just create an image, then execute one of these functions on the image resource. The image resource is passed by reference to the functions, so no return values are sent from the functions. Example shown in code.
// By: Ryand833
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1876&lngWId=8//for details.//**************************************

<?php
function flipVertical(&$img) {
 $size_x = imagesx($img);
 $size_y = imagesy($img);
 $temp = imagecreatetruecolor($size_x, $size_y);
 $x = imagecopyresampled($temp, $img, 0, 0, 0, ($size_y-1), $size_x, $size_y, $size_x, 0-$size_y);
 if ($x) {
$img = $temp;
 }
 else {
die("Unable to flip image");
 }
}
function flipHorizontal(&$img) {
 $size_x = imagesx($img);
 $size_y = imagesy($img);
 $temp = imagecreatetruecolor($size_x, $size_y);
 $x = imagecopyresampled($temp, $img, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y);
 if ($x) {
$img = $temp;
 }
 else {
die("Unable to flip image");
 }
}
$myimage = imagecreatefromjpeg("psclogo.jpg");
flipHorizontal($myimage);
header("Content-type: image/jpeg");
imagejpeg($myimage);
?>

将这一想法作为起点,你将做的是,每个图像(如您的以上)的斜体上,使用高/宽度来改变切片。

然后,请将每一件“被遗忘”的斜体上>magecopy,将其复制到你新的工作形象中。

See the image_flip function in comments at http://php.net/imagecopy

edit here is the exact link: http://cz2.php.net/manual/en/function.imagecopy.php#85992

将其落实到你的法典中,公正使用行文

$flippedOutput = ImageFlip($output,IMAGE_FLIP_HORIZONTAL);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签