Exemplo n.º 1
0
 /**
  * Load an image from a file. This method tries to detect the filetype
  * automatically and will abort if the automatic detection failed.
  *
  * \param $filename
  *   Filename of the image to load.
  *
  * \return
  *   A new AnewtImage instance
  */
 public static function from_file($filename)
 {
     assert('is_string($filename)');
     if (AnewtImage::_filename_looks_like_png($filename)) {
         $img = AnewtImage::from_png($filename);
     } elseif (AnewtImage::_filename_looks_like_jpeg($filename)) {
         $img = AnewtImage::from_jpeg($filename);
     } else {
         trigger_error(sprintf('AnewtImage::from_file(): Cannot load image, filename "%s" does not have a supported extension', $filename), E_USER_ERROR);
     }
     return $img;
 }
Exemplo n.º 2
0
 /** Crop image */
 static function crop()
 {
     $img = AnewtImage::from_png('test.png');
     $img->crop(50, 60, 400, 200);
     $img->flush_png();
     $img->destroy();
 }