0

I'm creating a comments system for my 'CMS' and would like to implement avatars. I would like to have a "getavatar.php" that uses a GET request to find an image for a certain user, while also doing some image processing.

Could anybody point me in the right direction for outputting data as "image/png" from a php script?

An example of this would be http://placehold.it/300x300 in the way it generates a 300x300 png image from the parameters given in the URL.

  • Usually you will process the graphics and save as files, either linked to user id, or just a temporary file. Then you do: `header("Content-Type: image/png"); readfile($filename);` in your script, and the browser will display the image. – Timothy Ha Nov 09 '14 at 14:29
  • As for image processing, there are many options in PHP, you can use http://php.net/imagecopyresampled for example. – Timothy Ha Nov 09 '14 at 14:31

1 Answers1

1

To output an image using PHP: Output an Image in PHP

To resize or edit an image using PHP: resize image in PHP

Both answers contains a lot of useful functions. Hope this help you.

Community
  • 1
  • 1
Berriel
  • 8,463
  • 3
  • 25
  • 54