0

Background: For an university project I have to use PHP5 to create a web application that also deals with images. I'm not allowed to use any external APIs, frameworks or AJAX.

Is there a native function to resize images in PHP5?

(I know a can specify both width and height for an img tag, but that resizing is done on the client. I'd rather save downsized images on the server.)

citronas
  • 19,035
  • 27
  • 96
  • 164
  • 1
    You can use GD if it's enabled in your PHP configuration. http://stackoverflow.com/questions/7393319/resize-images-with-php – MetalFrog Jan 23 '12 at 15:24
  • PHP has no native image manipulation functions. For that you need GD or Imagick, which are external libraries but generally available in most standard PHP installs. – Marc B Jan 23 '12 at 15:44

2 Answers2

4

The GD library has been bundled with PHP since 4.3, and will do what you want: http://uk.php.net/manual/en/book.image.php. You'll probably want something like imagecopyresampled.

Adam Wright
  • 48,938
  • 12
  • 131
  • 152
2

Most PHP installations come bundled with the GD library. In fact, I've yet to come across a PHP installation that doesn't have GD bundled.

Martin Bean
  • 38,379
  • 25
  • 128
  • 201