fork(1) download
  1. <?php
  2. $width = 100;
  3. $height = 100;
  4. $img = imagecreatefromjpeg("example.jpg");
  5.  
  6. $imageWidth =imagesx($img);
  7. $imageHeight = imagesy($img);
  8. if($imageWidth>$imageHeight){
  9. $newHeight=$height;
  10. $newWidth = floor($imageWidth*($height/$imageHeight));
  11. $x = floor($newWidth/2-$width/2);
  12. $y = 0;
  13. }
  14. elseif($imageWidth<$imageHeight){
  15. $newWidth = $width;
  16. $newHeight = floor($imageHeight*($width/$imageWidth));
  17. $y=floor($newHeight/2-$height/2);
  18. $x = 0;
  19. }
  20. $tempImage = imagecreatetruecolor($newWidth, $newHeight);
  21. imagecopyresampled($tempImage, $img, 0, 0, 0, 0, $newWidth, $newHeight, $imageWidth, $imageHeight);
  22.  
  23. $newImage = imagecreatetruecolor($width, $height);
  24. imagecopyresampled($newImage, $tempImage, 0, 0, $x, $y, $width, $height, $width, $height);
  25. imagejpeg($newImage, "thumbnails/example.jpg");
Runtime error #stdin #stdout #stderr 0.02s 52432KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Call to undefined function imagecreatefromjpeg() in /home/ZAdeAq/prog.php on line 4