BUenas tardes, la situacion es la siguente tengo imagenes guardadas en mi base de datos en mysql el problema es que tengo imagenes que tienen un tamaño muy grande, entonces quero descargar esas imagenes redimencionarlas y actualizar mi base de datos para que queden guardadas con el tamaño que requiero en mi php hago lo siguiente pero no funciona espero me puedan ayudar de antemano muchas gracias.
 
<?php
 
	include_once("connect.php");
 
	$sql =		"SELECT imagen FROM fotografia_inmueble WHERE id =493";
	$query =	mysql_query($sql);
 
	$row = mysql_fetch_array($query);
 
	$blobcontents = $row['imagen'];
 
	$im = imagecreatefromstring($blobcontents);
 
	$x = imagesx($im);
	$y = imagesy($im); 
 
	$ancho =350;
	$alto = 250;
 
	//Thumb más ancho que alto
	if($ancho > $alto){
 
		//Imagen original más ancha que alta
		if($x > $y){
 
			$dim = ($x/$y)/($ancho/$alto);
 
			if($dim < 1){
 
				$desired_width = $ancho;
				$desired_height = $y * $desired_width / $x;
			}
 
			else{
 
				$desired_height = $alto;
				$desired_width = $x * $desired_height / $y;
			}
		}
 
		//Imagen original más alta que ancha o igual
		else{
 
			if($dim < 1){
 
				$desired_width = $ancho;
				$desired_height = $y * $desired_width / $x;
			}
 
			else{
 
				$desired_height = $alto;
				$desired_width = $x * $desired_height / $y;
			}
		}
	}
 
	//Thumb más alto que ancho o igual
	else if($ancho < $alto){
 
		//Imagen original más ancha que alta
		if($x > $y){
 
			$dim = ($x/$y)/($ancho/$alto);
 
			if($dim < 1){
 
				$desired_width = $ancho;
				$desired_height = $y * $desired_width / $x;
			}
 
			else{
 
				$desired_height = $alto;
				$desired_width = $x * $desired_height / $y;
			}
		}
 
		//Imagen original más alta que ancha o igual
		else{
 
			if($dim > 1){
 
				$desired_width = $ancho;
				$desired_height = $y * $desired_width / $x;
			}
 
			else{
 
				$desired_height = $alto;
				$desired_width = $x * $desired_height / $y;
			}
		}
	}
 
	//Thumb alto igual que ancho
	else{
 
		$dim = ($x/$y)/($ancho/$alto);
 
		if($dim < 1){
 
			$desired_width = $ancho;
			$desired_height = $y * $desired_width / $x;
		}
 
		else{
 
			$desired_height = $alto;
			$desired_width = $x * $desired_height / $y;
		}
	}
 
	$new = imagecreatetruecolor($ancho, $alto);
 
	if($ancho > $alto)
		imagecopyresampled($new, $im, 0, floor(-($desired_height - $alto)/2), 0, 0, $desired_width, $desired_height, $x, $y);
	else
		imagecopyresampled($new, $im, floor(-($desired_width - $ancho)/2), 0, 0, 0, $desired_width, $desired_height, $x, $y);
 
	//imagedestroy($im);
 
	$sql="update fotografia_imueble set imagen='".$im."' where id=493";
   mysql_query($sql);
?> 
   
 

