Skip to main content

Greyscale

const blackAndWhiteVideo = modfy.greyscale(
{
inputFiles: [videoFile],
greyscale: true
},
'sync' // Can be 'async' | 'sync' | 'client',
'https://yourdomain.com/modfyWebhook' // When using async must pass this paramater
)

Arguments#

This operation has three arguments:

  1. An array of input files (more about files here)
  2. Type of processing: client or server or async. More about processing types here
  3. A boolean signifying whether or not this operation is enabled

Full class reference is below

Typing#

modfy.greyscale(
{
inputFiles: AcceptedFiles,
greyscale: boolean
},
processType: ProcessType,
webhookUrl?: string
): Promise<Uint8Array> | Promise<{ id: string, uuid: string }>
type ProcessType = "sync" | "client" | "async"
/**
* This interface is a wrapper for a file object which takes a buffer
* with the mimeType and name of the file
*/
type ModfyFile = {
name: string
mimeType?: string
buffer: Buffer
}
type StoredFiles = File[] | ModfyFile[]
/**
* This type represents the accepted file inputs
*
* There are three accepted file input types
* 1. Array of Html File Object
* 2. Array of Strings, File Paths (Node only)
* 3. Array of {buffer, name, mimeType}
Here we are supporting buffers directly but require that you provide the name and mimeType
*/
type AcceptedFiles = StoredFiles | string[]

Caveats#

  • All files in the input array must be of same type
  • String paths are only supported in node

Example#

// Snippet
// File here is a HTML File directly from DOM input
const greyscaleFile = modfy.convert(
{
inputFiles: [videoFile],
greyscale: true
},
'sync' // Can be 'async' | 'sync' | 'client',
'https://yourdomain.com/modfyWebhook' // When using async must pass this paramater
)