Redimencionar imagen php help please

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

Edrien

Préstamo en curso
Lambda
Verificación en dos pasos activada
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.
 
¿Te sirvió? Únete a la conversación

Con tu cuenta gratis puedes responder, escribirle al autor por mensaje privado y comprar con Saldo retenido: el pago se libera cuando recibes lo acordado.

Toma 30 segundos · vuelves a este tema al terminar
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