private static function imageTypeToExtension($type)
    {
        $type = (int)$type;

        switch ($type) {
            case 2:
                $format = 'JPEG';
                break;

            case 4:
                $format = 'PNG';
                break;

            default:
                $format = 'UNSUPPORTED';
        }
        return $format;
    }