Ver Mensaje Individual
  #8 (permalink)  
Antiguo 25/05/2009, 05:06
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Reescalar imagen - Guardarla luego

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$sourceImageIdentifier0$y0$sourceImageHeight $y 1$sourceImageWidth1);

            }
            
            
// 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();