<html>
  <head></head>
  <body>
<pre><?php

include('SimpleImage.php');

function show_image_info($file) {
  if (!is_file($file)) {
    echo $file." is not a file\n";
    return FALSE;
  }

  $data = @getimagesize($file);
  $file_size = @filesize($file);

  if (isset($data) && is_array($data)) {
    echo "Details: ".$file." ".$data[0]."x".$data[1]." mime:".$data['mime']." size:".$file_size."\n";
  } else {
    echo "Unable to get details for ".$file." size:".$file_size."\n";
    return FALSE;
  }

  return TRUE;
}

// Works 100%
if( show_image_info('images/budgerigar-100.jpg') ) {
  $image = new SimpleImage();
  $image->load('images/budgerigar-100.jpg');
  $image->resizeToWidth(200);
  $image->save('images/budgerigar-100.small.jpg', IMAGETYPE_JPEG);
  show_image_info('images/budgerigar-100.small.jpg');
}

// Fails to create valid scaled image
if( show_image_info('images/world-map.gif') ) {
  $image = new SimpleImage();
  $image->load('images/world-map.gif');
  $image->resizeToWidth(200);
  $image->save('images/world-map.small.gif', IMAGETYPE_GIF);
  show_image_info('images/world-map.small.gif');
}

// Fails to load original image
if( show_image_info('images/drink.jpg') ) {
  $image = new SimpleImage();
  $image->load('images/drink.jpg');
  $image->resizeToWidth(200);
  $image->save('images/drink.small.jpg');
  show_image_info('images/drink.small.jpg', IMAGETYPE_JPEG);
}

?></pre>
  </body>
</html>
