/** * Constructor * * Parses arguments, looks for a command, and hands off command * options to another Relic library function. */ public function __construct() { $this->_parseArgs(); if (array_key_exists($this->command, $this->commands)) { $args = $this->_parseOpts($this->commands[$this->command]['options'], $this->commands[$this->command]['params']); switch ($this->command) { case 'thumb': Image::thumbnail($args['params']['image'], $args['params']['dst'], $args['options']); break; case 'split': PDF::split($args); break; case 'metadata': $mime = Mime::mime($args['params']['file']); if (in_array($mime, array('image/jpg', 'image/jpeg', 'image/tiff'))) { $image = new Image($args['params']['file']); $this->prettyPrint($image->exif()); } else { if ($mime == 'application/pdf') { $pdf = new PDF($args['params']['file']); $this->prettyPrint($pdf->info); } } break; case 'mime': Mime::printMime($args['params']['file']); break; } } else { $this->_usage(false, 'Unknown command.'); exit(1); } }