public static function create($path, $format)
    {
        switch ($format) {
            case IMAGETYPE_JPEG:
                $result = imagecreatefromjpeg($path);
                break;
            case IMAGETYPE_PNG:
                $result = imagecreatefrompng($path);
                break;
            case IMAGETYPE_GIF:
                $result = imagecreatefromgif($path);
                break;
        }

        if (!$result) {
            throw new \Exception("Failing to create image (" . $path . ")");
        }

        return $result;
    }