@io-arc/webp-converter
PNG, JPG, GIF files to Webp files conversions. What's Webp?
Using to imagemin.
PNG, JPG is imagemin-webp.
GIF is imagemin-imagemin-gif2webp.
Using RxJS (library included).
Usage#
Methods#
Instance parameters#
| params | type | default | description |
|---|---|---|---|
targetDir | string[] | - | Target directory name array |
ext | {png: boolean, jpg: boolean, gif: boolean} | {png: true, jpg: true, gif: false} | Target extensions |
options | imageminWebp.Options | undefined | PNG/JPG convert options |
gifOptions | IfGif2WebpOptions | undefined | GIF convert options |
outputDir | string[] | Same as targetDir parameter | Output directory name array |
directory name array is /src/img => ['src', 'img'].
noTarget()#
Return: boolean
If target the extension to be converted is all false.
Example
targetDirectory()#
Return: string
Directory path where the extension to be converted exists.
Example
regExp4FileExtensions()#
Return: RegExp
Regular expression for target extension.
Example
convertAll()#
Return: RxJS.Observable<string>
Converts all target.
Except for files that begin with an underscore.
Example
convert(filepath)#
Return: RxJS.Observable<string>
Convert the specified file.
The filepath does not have to be the directory specified in the constructor.
However, the output destination will be the directory specified in the constructor.
Parameters
| params | type | default | description |
|---|---|---|---|
filepath | string | - | The file path to which you want to convert |
Example
removeAll()#
Return: RxJS.Observable<string>
Remove all webp files in the output directory specified by outputDir.
Example
remove(filepath)#
Return: RxJS.Observable<string>
Remove the specified file.
The filepath does not have to be the directory specified in the constructor.
Parameters
| params | type | default | description |
|---|---|---|---|
filepath | string | - | The file path to which you want to convert |
Example