Redimencionar imagen php help please

  • Autor Autor Edrien
  • Fecha de inicio Fecha de inicio
Edrien

Edrien

Lambda
Verificación en dos pasos activada
Verificado por Whatsapp
Buenas alguien tendera algún código php, para dimensionar solo el tamaño de una imagen, es decir un ejemplo:

miweb.com/resize.jpg?w=143&h=80&url=LA URL DE LA IMAGEN.

solo el tamaño.
 
Con este código es simple

PHP:
<?php
function resize_imagejpg($file, $w, $h) {
   list($width, $height) = getimagesize($file);
   $src = imagecreatefromjpeg($file);
   $dst = imagecreatetruecolor($w, $h);
   imagecopyresampled($dst, $src, 0, 0, 0, 0, $w, $h, $width, $height);
   return $dst;
}
function resize_imagepng($file, $w, $h) {
   list($width, $height) = getimagesize($file);
   $src = imagecreatefrompng($file);
   $dst = imagecreatetruecolor($w, $h);
   imagecopyresampled($dst, $src, 0, 0, 0, 0, $w, $h, $width, $height);
   return $dst;
}
  $foto = 'foto.jpg';
  $test =  resize_imagejpg($foto, 550, 550);
  imagejpeg($test, 'foto_nueva.jpg');
 
Con este código es simple

PHP:
<?php
function resize_imagejpg($file, $w, $h) {
   list($width, $height) = getimagesize($file);
   $src = imagecreatefromjpeg($file);
   $dst = imagecreatetruecolor($w, $h);
   imagecopyresampled($dst, $src, 0, 0, 0, 0, $w, $h, $width, $height);
   return $dst;
}
function resize_imagepng($file, $w, $h) {
   list($width, $height) = getimagesize($file);
   $src = imagecreatefrompng($file);
   $dst = imagecreatetruecolor($w, $h);
   imagecopyresampled($dst, $src, 0, 0, 0, 0, $w, $h, $width, $height);
   return $dst;
}
  $foto = 'foto.jpg';
  $test =  resize_imagejpg($foto, 550, 550);
  imagejpeg($test, 'foto_nueva.jpg');

imagejpeg($test, 'foto_nueva.jpg');

en esta parte pondria la ruta de la iamgen verdad¨='?
 

Temas similares

S
Respuestas
3
Visitas
530
imported_OLMID
I
Atrás
Arriba