You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Same as toBuffer, but writes output to a Uint8Array.
121
+
*
122
+
* @example
123
+
* sharp(input)
124
+
* .toBuffer((err, data, info) => { ... });
125
+
*
126
+
* @example
127
+
* sharp(input)
128
+
* .toUint8Array()
129
+
* .then(data => { ... })
130
+
* .catch(err => { ... });
131
+
*
132
+
* @example
133
+
* sharp(input)
134
+
* .toUint8Array({ resolveWithObject: true })
135
+
* .then(({ data, info }) => { ... })
136
+
* .catch(err => { ... });
137
+
*
138
+
* @param {Object} [options]
139
+
* @param {boolean} [options.resolveWithObject] Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.
140
+
* @param {Function} [callback]
141
+
* @returns {Promise<Buffer>} - when no callback is provided
142
+
*/
143
+
functiontoUint8Array(options,callback){
144
+
returnnewPromise((resolve,reject)=>{
145
+
this.toBuffer(options,callback).then((buff)=>{
146
+
resolve(Uint8Array.from(buff));
147
+
})
148
+
});
149
+
}
150
+
119
151
/**
120
152
* Include all metadata (EXIF, XMP, IPTC) from the input image in the output image.
121
153
* This will also convert to and add a web-friendly sRGB ICC profile.
@@ -797,6 +829,7 @@ module.exports = function (Sharp) {
0 commit comments