Este codigo lo saque de una clase que hize para subir fotos y redimencionarla.
Esta parte es la que se encarga de hacer el thumb en 150px por lado.
Me avisas si no puedes hacerlo, te paso la class completa, no me deja postearla porque supera el numero permitido de caracteres.
Código PHP:
function Thumb(){
if ($this->listo_thumb == true){
$this->imagen_thumb = imagecreatefromjpeg($this->carpeta . $this->newname);
$this->img_thumb = imagecreatetruecolor(150, 150);
$this->new_ancho2 = imagesx($this->imagen_thumb);
$this->new_alto2 = imagesy($this->imagen_thumb);
$this->ancho_thumb_max = 150;
$this->alto_thumb_max = 150;
if($this->ancho_thumb_max/$this->new_ancho2 > $this->alto_thumb_max/$this->new_alto2)
{
$this->ancho_thumb = $this->ancho_thumb_max;
$this->alto_thumb = ($this->new_alto2 * $this->ancho_thumb) / $this->new_ancho2;
$this->image_x = 0;
$this->image_y = ($this->alto_thumb_max - $this->alto_thumb) / 2;
}
else
{
$this->alto_thumb = $this->alto_thumb_max;
$this->ancho_thumb = ($this->new_ancho2 * $this->alto_thumb) / $this->new_alto2;
$this->image_y = 0;
$this->image_x = ($this->ancho_thumb_max - $this->ancho_thumb) / 2;
}
imagecopyresampled($this->img_thumb, $this->imagen_thumb, $this->image_x, $this->image_y, 0, 0, $this->ancho_thumb, $this->alto_thumb, $this->new_ancho2, $this->new_alto2);
$this->copy_thumb = imagejpeg($this->img_thumb,$this->carpeta . "thumb/" . $this->newname, 80);
if ($this->copy_thumb){
imagedestroy($this->img_thumb);
imagedestroy($this->imagen_thumb);
$this->message = "Copiado correctamente Thumb <br />";
echo $this->carpeta . "thumb/" . $this->newname . "<br />";
}
}
}function Thumb(){
if ($this->listo_thumb == true){
$this->imagen_thumb = imagecreatefromjpeg($this->carpeta . $this->newname);
$this->img_thumb = imagecreatetruecolor(150, 150);
$this->new_ancho2 = imagesx($this->imagen_thumb);
$this->new_alto2 = imagesy($this->imagen_thumb);
$this->ancho_thumb_max = 150;
$this->alto_thumb_max = 150;
if($this->ancho_thumb_max/$this->new_ancho2 > $this->alto_thumb_max/$this->new_alto2)
{
$this->ancho_thumb = $this->ancho_thumb_max;
$this->alto_thumb = ($this->new_alto2 * $this->ancho_thumb) / $this->new_ancho2;
$this->image_x = 0;
$this->image_y = ($this->alto_thumb_max - $this->alto_thumb) / 2;
}
else
{
$this->alto_thumb = $this->alto_thumb_max;
$this->ancho_thumb = ($this->new_ancho2 * $this->alto_thumb) / $this->new_alto2;
$this->image_y = 0;
$this->image_x = ($this->ancho_thumb_max - $this->ancho_thumb) / 2;
}
imagecopyresampled($this->img_thumb, $this->imagen_thumb, $this->image_x, $this->image_y, 0, 0, $this->ancho_thumb, $this->alto_thumb, $this->new_ancho2, $this->new_alto2);
$this->copy_thumb = imagejpeg($this->img_thumb,$this->carpeta . "thumb/" . $this->newname, 80);
if ($this->copy_thumb){
imagedestroy($this->img_thumb);
imagedestroy($this->imagen_thumb);
$this->message = "Copiado correctamente Thumb <br />";
echo $this->carpeta . "thumb/" . $this->newname . "<br />";
}
}
}