Output to browser

This simple example shows how to resize an image and output it directly to the browser. Bare in mind that the code needs security checks, which I left out for brevity.

The file name of the image is read from img GET parameter.

  1. $img = WideImage::load($_GET['img']);

The image is resized …

  1. $resized = $img->resize(500, 300);

And output to browser in JPG format with quality set to 90%.

  1. $resized->output('jpg', 90);

All this can be done as a one-liner:

  1. WideImage::load($_GET['img'])->resize(500, 300)->output('jpg', 90);
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Reddit
  • Tumblr
  • Twitter