-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71cee15
commit 30618cb
Showing
3 changed files
with
84 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* Determines whether a given file type is supported by vips. | ||
* | ||
* @param type Mime type. | ||
* @return Whether the file type is supported. | ||
*/ | ||
export function isFileTypeSupported( | ||
type: string | ||
): type is | ||
| 'image/jpeg' | ||
| 'image/png' | ||
| 'image/webp' | ||
| 'image/avif' | ||
| 'image/gif' { | ||
return [ | ||
'image/jpeg', | ||
'image/png', | ||
'image/webp', | ||
'image/avif', | ||
'image/gif', | ||
].includes( type ); | ||
} | ||
|
||
/** | ||
* Determines whether a given file type supports a quality setting, | ||
* | ||
* @todo Make this smarter. | ||
* | ||
* @param type Mime type. | ||
* @return Whether the file supports a quality setting. | ||
*/ | ||
export function supportsQuality( | ||
type: string | ||
): type is 'image/jpeg' | 'image/png' | 'image/webp' | 'image/avif' { | ||
return [ 'image/jpeg', 'image/png', 'image/webp', 'image/avif' ].includes( | ||
type | ||
); | ||
} | ||
|
||
/** | ||
* Determines whether a given file type supports animation, | ||
* | ||
* @todo Make this smarter. | ||
* | ||
* @param type Mime type. | ||
* @return Whether the file supports animation. | ||
*/ | ||
export function supportsAnimation( type: string ): type is 'image/webp' | 'image/gif' { | ||
return [ 'image/webp', 'image/gif' ].includes( type ); | ||
} | ||
|
||
/** | ||
* Determines whether a given file type supports interlaced/progressive output. | ||
* | ||
* @todo Make this smarter. | ||
* | ||
* @param type Mime type. | ||
* @return Whether the file supports interlaced/progressive output. | ||
*/ | ||
export function supportsInterlace( | ||
type: string | ||
): type is 'image/jpeg' | 'image/gif' | 'image/png' { | ||
return [ 'image/jpeg', 'image/gif', 'image/png' ].includes( type ); | ||
} |