forked from deriv-com/deriv-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
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
c7e5aea
commit c01fc86
Showing
2 changed files
with
91 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# document | ||
|
||
### supportedDocumentFormats | ||
|
||
```JS | ||
["PNG", "JPG", "JPEG", "GIF", "PDF"] | ||
``` |
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,80 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# image | ||
|
||
### compressImage | ||
|
||
Compress an image and return it as a Blob by utilizing a Promise that resolves with the compressed image as a Blob (`Promise<Blob>`). | ||
|
||
#### Options | ||
|
||
- `src[required]: string` - The source image URL or data URI. | ||
- `filename[required]: string` - The desired filename for the compressed image. | ||
- `options[optional]: {maxWidth?: number; quality?: number;}` - Options for image compression. | ||
|
||
-- **maxWidth [default: 2560]** The maximum width for the compressed image. | ||
|
||
-- **quality [default: 0.9]** - The image quality (0 to 1) for compression. | ||
|
||
### convertToBase64 | ||
|
||
Convert a File to a Base64 encoded image representation. | ||
|
||
It returns a Promise that resolves with an object containing the Base64 image data and the filename. `Promise<{filename: string; src: string}>` | ||
|
||
#### Options | ||
|
||
- `file[required]: File` - The File object to convert to Base64. | ||
|
||
### isSupportedImageFormat | ||
|
||
Check if a given filename has a supported image format extension. | ||
|
||
It returns **True** if the filename has a supported image format extension, **false** otherwise. | ||
|
||
#### Options | ||
|
||
- `filename[required]: string` - The filename to check for a supported image format. | ||
|
||
### compressImageFile | ||
|
||
Convert image to base64 and compress an image file if it is a supported image format. | ||
|
||
It returns a Promise that resolves with the compressed image as a Blob. `Promise<Blob>` | ||
|
||
#### Options | ||
|
||
- `file[required]: File` - The File object to compress. | ||
|
||
### numToUint8Array | ||
|
||
Get Uint8Array from number. | ||
|
||
It returns `Uint8Array`. | ||
|
||
#### Options | ||
|
||
- `num[required]: number` - The number to convert to Uint8Array. | ||
- `arraySize[optional]: number` - default 4. | ||
|
||
### generateChunks | ||
|
||
Turn binary into array of chunks. | ||
|
||
It returns an array of Uint8Array chunks. `Uint8Array[]` | ||
|
||
#### Options | ||
|
||
- `binary[required]: Uint8Array` - Uint8Array to be chunked. | ||
|
||
### readFile | ||
|
||
Read a file and return it as modified object with a buffer of the file contents. | ||
|
||
It returns a Promise that resolves with the file as a TFileObject. `Promise<{filename?: File["name"]; buffer: FileReader["result"]; fileSize: File["size"];}>` | ||
|
||
#### Options | ||
|
||
- `file[required]: Blob` - The file to read. |