Learning & Integrating web technology and code help directory

How to use PHP & Resize image

No comments
How to use PHP & Resize image The guideline/example scripts how to using PHP and GD , Resize image
Example
php_resize.php
  1. <?  
  2. $images = "mygirl.jpg";  
  3. $new_images = "MyResize/mygirl.jpg";  
  4. $width=200; //*** Fix Width & Heigh (Auto calculate) ***//  
  5. $size=GetimageSize($images);  
  6. $height=round($width*$size[1]/$size[0]);  
  7. $images_orig = ImageCreateFromJPEG($images);  
  8. $photoX = ImagesX($images_orig);  
  9. $photoY = ImagesY($images_orig);  
  10. $images_fin = ImageCreateTrueColor($width$height);  
  11. ImageCopyResampled($images_fin$images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX$photoY);  
  12. ImageJPEG($images_fin,$new_images);  
  13. ImageDestroy($images_orig);  
  14. ImageDestroy($images_fin);  
  15. ?>  
  16. <b>Original Size</b><br>  
  17. <img src="<?=$images;?>">  
  18. <hr>  
  19. <b>New Resize</b><br>  
  20. <img src="<?=$new_images;?>">  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Resize image

No comments :

Post a Comment