[Resolvido] Problema com Upload(crop) GD
Olá,
Estou tendo problemas com um crop de imagem no servidor em que eu subi a minha aplicação. Local tudo está funcionando normalmente, já ví o phpinfo() dos dois e estão praticamente iguais, porém quando subi ao fazer o upload da imagem recebo o seguinte erro:
>
error : No JPEG create support.
e
Dentro da Classe que estou usando encontei :
>
$this->translation['file_create'] = 'No %s create support.';
case 'jpg':
if (!$return_mode) {
$result = @imagejpeg($image_dst, $this->file_dst_pathname, $this->jpeg_quality);} else {
ob_start();
$result = @imagejpeg($image_dst, null, $this->jpeg_quality);
$return_content = ob_get_contents();
ob_end_clean();
}
if (!$result) {
$this->processed = false;
$this->error = $this->translate('file_create', array('JPEG'));} else {
$this->log .= ' JPEG image created<br />';
}
break;
Estou usando esta classe de upload:
http://www.phpclasses.org/browse/file/8831.html
e esta função para o crop:
protected function resizeImagejCrop( array $fileArray, $prefix = null, array $coords, $widthInBrowser, array $finalSize, array $oldSize, $outputFile = "file", $delete_original = true )
{
# Setting defaults and meta
list( $path, $filename ) = $fileArray;
list( $x, $y ) = $coords;
list( $width_old, $height_old ) = $oldSize;
list( $final_width, $final_height ) = $finalSize;
$file = implode( "", $fileArray );
$info = getimagesize( $file );
$image = "";
$output = $path . $prefix . $filename;
require_once "class.upload.php";
$handle = new upload( $path . $filename );
$handle->image_resize = true;
$handle->image_x = $widthInBrowser[ 1 ];
$handle->image_y = $widthInBrowser[ 3 ];
$handle->file_overwrite = true;
$handle->Process( $path );
if( !is_null( $output ) && is_file( $output ) )
{
// unlink( $output );
}
# Loading image to memory according to type
switch( $info[ 2 ] )
{
case IMAGETYPE_GIF: $image = imagecreatefromgif( $file );
break;
case IMAGETYPE_JPEG: $image = imagecreatefromjpeg( $file );
break;
case IMAGETYPE_PNG: $image = imagecreatefrompng( $file );
break;
default: return false;
}
$trnprt_indx = imagecolortransparent( $image );
$trnprt_color = array( "red" => 255, "green" => 255, "blue" => 255 );
# This is the resizing/resampling/transparency-preserving magic
$image_resized = imagecreatetruecolor( $final_width, $final_height );
if( ( $info[ 2 ] == IMAGETYPE_GIF ) || ( $info[ 2 ] == IMAGETYPE_PNG ) )
{
$transparency = imagecolortransparent( $image );
if( $transparency >= 0 )
{
$transparent_color = imagecolorsforindex( $image, $trnprt_indx );
$transparency = imagecolorallocate( $image_resized, $trnprt_color[ "red" ], $trnprt_color[ "green" ], $trnprt_color[ "blue" ] );
imagefill( $image_resized, 0, 0, $transparency );
imagecolortransparent( $image_resized, $transparency );
}
elseif( $info[ 2 ] == IMAGETYPE_PNG )
{
imagealphablending( $image_resized, false );
$color = imagecolorallocatealpha( $image_resized, 0, 0, 0, 127 );
imagefill( $image_resized, 0, 0, $color );
imagesavealpha( $image_resized, true );
}
}
imagecopyresampled( $image_resized, $image, 0, 0, $x, $y, $final_width, $final_height, $width_old, $height_old );
# Preparing a method of providing result
switch( strtolower( $outputFile ) )
{
case "browser":
$mime = image_type_to_mime_type( $info[ 2 ] );
header( "Content-type: $mime" );
$output = NULL;
break;
case "file":
break;
case "return":
return $image_resized;
break;
default:
break;
}
# Writing image according to type to the output destination
switch( $info[ 2 ] )
{
case IMAGETYPE_GIF: imagegif( $image_resized, $output, 95 );
break;
case IMAGETYPE_JPEG: imagejpeg( $image_resized, $output, 95 );
break;
case IMAGETYPE_PNG: imagepng( $image_resized, $output, 95 );
break;
default: return false;
}
# Taking care of original, if needed
if( $delete_original )
{
// unlink( $file );
}
return true;
}Discussão (11)
Carregando comentários...