continuar
Código PHP:
/**
* Flips vertically the image given as {@link sourceFile} and outputs the resulted image as {@link targetFile}
*
* @return boolean TRUE on success, FALSE on error.
* If FALSE is returned, check the {@link error} property to see what went wrong
*/
function flip_vertical()
{
// tries to create an image from sourceFile
$result = $this->create_image_from_source_file();
// if operation was successful
if (is_array($result)) {
list($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight) = $result;
// prepares the target image
$targetImageIdentifier = $this->create_target_image_identifier($sourceImageWidth, $sourceImageHeight);
// flips image vertically
for ($y = 0; $y < $sourceImageHeight; $y++) {
imagecopyresampled($targetImageIdentifier, $sourceImageIdentifier, 0, $y, 0, $sourceImageHeight - $y - 1, $sourceImageWidth, 1);
}
// writes image
return $this->output_target_image($targetImageIdentifier);
// if new image resource could not be created
} else {
// return false
// note that we do not set the error level as it has been already set
// by the create_image_from_source_file() method earlier
return false;
}
}
/**
* Rotates the image given as {@link sourceFile} and outputs the resulted image as {@link targetFile}
*
* this method implements PHP's imagerotate method which is buggy.
* an improved version of this method should be available soon
*
* @param double $angle angle to rotate the image by
* @param mixed $bgColor the color of the uncovered zone after the rotation
*
* @return boolean TRUE on success, FALSE on error.
* If FALSE is returned, check the {@link error} property to see what went wrong
*/
function rotate($angle, $bgColor)
{
// tries to create an image from sourceFile
$result = $this->create_image_from_source_file();
// if operation was successful
if (is_array($result)) {
list($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight, $sourceImageType) = $result;
// rotates image
$targetImageIdentifier = imagerotate($sourceImageIdentifier, $angle, $bgColor);
// writes image
return $this->output_target_image($targetImageIdentifier);
// if new image resource could not be created
} else {
// return false
// note that we do not set the error level as it has been already set
// by the create_image_from_source_file() method earlier
return false;
}
}
}
foreach($_FILES as $key => $value){
foreach($value as $key2 => $value2){
if($key2 == "name"){
$srcImg = $value2;
}
if($key2 == "tmp_name"){
$srcImg_tmp = $value2;
}
if($key2 == "type"){
$srcImg_type = $value2;
}
}
}
$txtname = "image.jpg"
@move_uploaded_file($srcImg_tmp, $txtname);
$getResizeFile = "directorio/".$txtname;
$imgTrans = new imageTransform();
$imgTrans->sourceFile = $txtname;
$imgTrans->targetFile = $getResizeFile;
$imgTrans->resizeToHeight = 200;
$imgTrans->resize();