function resize($width, $height, $flags = self::FIT) { if ($this->file === NULL) { return parent::resize($width, $height, $flags); } $mirror = ''; if ($width < 0) { $mirror .= ' -flop'; } if ($height < 0) { $mirror .= ' -flip'; } list($newWidth, $newHeight) = self::calculateSize($this->getWidth(), $this->getHeight(), $width, $height, $flags); $this->execute("convert -resize {$newWidth}x{$newHeight}! {$mirror} -strip %input %output", self::PNG); return $this; }