PHP Classes
elePHPant
Icontem

i want to resize image class: want resize exact width and height image which i provided.

Recommend this page to a friend!
  All requests RSS feed  >  i want to resize image class  >  Request new recommendation  >  A request is featured when there is no good recommended package on the site when it is posted. Featured requests  >  No recommendations No recommendations  

i want to resize image class

Edit

by Keith G - 4 months ago (2018-05-01)

want resize exact width and height image which i provided.

This request is clear and relevant.
This request is not clear or is not relevant.

+2

i want resize image code whatever image is height or width.

  • 1 Clarification request
  • 1. by riccardo castagna - 3 months ago (2018-05-29) Reply

    may be this will be usefull for your problem : the php working code with jpeg is: <?php $source_image = imagecreatefromjpeg("osaka.jpg"); $source_imagex = imagesx($source_image); $source_imagey = imagesy($source_image); $dest_imagex = 300; $dest_imagey = 200; $dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey); imagecopyresampled($dest_image, $source_image, 0, 0, 0, 0, $dest_imagex, $dest_imagey, $source_imagex, $source_imagey);

    imagejpeg($dest_image,NULL,80); ?> This example scales and compress a jpeg image but you will be able to add others php functions like (imagecreatefromgif() and imagegif() ) for gif images for example and (imagecreatefrompng() and imagepng() ) ... etc .. etc.

    • 2. by riccardo castagna - 3 months ago (2018-05-29) in reply to comment 1 by riccardo castagna Comment

      for whatever image you can do in this way and you in this way you will be able to compress the image and also convert into webp (for exaple) :

      $filename = "./an_image.png";

      $size = getimagesize($filename); list($width, $height) = $size; if (!file_exists($fileWebP)){ switch ($size['mime']) {

      case "image/gif": 
          $im = imagecreatefromgif($filename); 
          break; 
      case "image/jpeg": 
          $im = imagecreatefromjpeg($filename);       
          break; 
      case "image/png": 
          $im = imagecreatefrompng($filename);  
          break; 
      case "image/bmp": 
          $im = imagecreatefrombmp($filename); 
          break; 
      

      } $source_imagex = imagesx($im); $source_imagey = imagesy($im); $dest_imagex = 300; $dest_imagey = 150; $dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey); imagecopyresampled($dest_image, $im, 0, 0, 0, 0, $dest_imagex, $dest_imagey, $source_imagex, $source_imagey); $fileWebP = "./newimage.webp"; imagewebp($dest_image, $fileWebP, 60);

Ask clarification

2 Recommendations

Speed Image Load: Resize images in GIF, JPEG, PNG and WebP format

This recommendation solves the problem.
This recommendation does not solve the problem.

0

by riccardo castagna package author package author Reputation 75 - 3 months ago (2018-06-10) Comment

This package solve the problem of resizing image and also it is possible to convert the original image source file into a new lighter webp image file or into other format. And also it is possible to compress the image file. It is possible to set the transparency. In my example there is also explained a method to load faster the web page if you have to load, for example, a lot of images in only one page. A load event listener load at the beginning only three images and a scroll event listener defer the others.


PHP Image Sizer: Resize images to a given width and height

This recommendation solves the problem.
This recommendation does not solve the problem.

0

by zinsou A.A.E.Moïse Reputation 5350 - 4 months ago (2018-05-04) Comment

there are severals packages in the repository but this is one of the best i have tried and which i used in many of my packages for this purpose...Just try it and let us know.


Recommend package
: 
: