Hashing Utilities¶
Provides functions to compute MD5 and SHA1 hashes from a readable stream, will also resize the image to 448x448 as required if requested.
- computeHashesFromStream(data: Readable | Buffer<ArrayBufferLike>, encoding: RequestEncoding = RequestEncoding.REQUEST_ENCODING_UNCOMPRESSED, imageFormat: ImageFormat = ImageFormat.IMAGE_FORMAT_UNSPECIFIED, resize: boolean = false, hashes: HashType[] = [HashType.HASH_TYPE_MD5, HashType.HASH_TYPE_SHA1]): Promise<{ md5?: string | undefined; sha1?: string | undefined; data: Buffer; format: ImageFormat; }> [source]¶
Computes MD5 and SHA1 hashes from a readable stream and resizes any image data.
Parameters:
streamNode.js readable stream (e.g., fs.createReadStream)
encodingEncoding type for the image data (default is UNCOMPRESSED)
imageFormatFormat of the input image (default is UNSPECIFIED)
resizeWhether to resize the image to 448x448 pixels (default is false)
hashesArray of hash types to compute (default is [MD5, SHA1])
Returns:
{Promise<{md5?: string, sha1?: string, data: Buffer}>} Object containing MD5 hash, SHA1 hash, and resized image buffer
Parameters¶
data: Readable | Buffer<ArrayBufferLike>encoding: RequestEncoding = RequestEncoding.REQUEST_ENCODING_UNCOMPRESSEDEncoding type for the image data (default is UNCOMPRESSED)
imageFormat: ImageFormat = ImageFormat.IMAGE_FORMAT_UNSPECIFIEDFormat of the input image (default is UNSPECIFIED)
resize: boolean = falseWhether to resize the image to 448x448 pixels (default is false)
hashes: HashType[] = [HashType.HASH_TYPE_MD5, HashType.HASH_TYPE_SHA1]Array of hash types to compute (default is [MD5, SHA1])
Returns
Promise<{ md5?: string | undefined; sha1?: string | undefined; data: Buffer; format: ImageFormat; }> - {Promise<{md5?: string, sha1?: string, data: Buffer}>} Object containing MD5 hash, SHA1 hash, and resized image buffer