@@ -288,36 +288,83 @@ exports.text = function text(content, callback) {
288288 } ) ;
289289} ;
290290
291+ /**
292+ * Generate a sprite by merging multiple images into a single large image for reducing network overhead and bypassing
293+ * download limitations.
294+ *
295+ * The process produces 2 files as follows:
296+ * - A single image file containing all the images with the specified tag (PNG by default).
297+ * - A CSS file that includes the style class names and the location of the individual images in the sprite.
298+ *
299+ * @param {String|Object } tag A string specifying a tag that indicates which images to include or an object
300+ * which includes options and image URLs.
301+ * @param {Function } callback Callback function
302+ * @param {Object } options Configuration options. If options are passed as the first parameter, this parameter
303+ * should be empty
304+ *
305+ * @return {Object }
306+ */
291307exports . generate_sprite = function generate_sprite ( tag , callback ) {
292308 var options = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
293309
294310 return call_api ( "sprite" , callback , options , function ( ) {
295- var transformation = utils . generate_transformation_string ( extend ( { } , options , {
296- fetch_format : options . format
297- } ) ) ;
298- return [ {
299- timestamp : utils . timestamp ( ) ,
300- tag : tag ,
301- transformation : transformation ,
302- async : options . async ,
303- notification_url : options . notification_url
304- } ] ;
311+ return [ utils . build_multi_and_sprite_params ( tag , options ) ] ;
305312 } ) ;
306313} ;
307314
315+ /**
316+ * Returns a signed url to download a sprite
317+ *
318+ * @param {String|Object } tag A string specifying a tag that indicates which images to include or an object
319+ * which includes options and image URLs.
320+ * @param {Object } options Configuration options. If options are passed as the first parameter, this parameter
321+ * should be empty
322+ *
323+ * @returns {string }
324+ */
325+ exports . download_generated_sprite = function download_generated_sprite ( tag ) {
326+ var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
327+
328+ return utils . api_download_url ( "sprite" , utils . build_multi_and_sprite_params ( tag , options ) , options ) ;
329+ } ;
330+
331+ /**
332+ * Returns a signed url to download a single animated image (GIF, PNG or WebP), video (MP4 or WebM) or a single PDF from
333+ * multiple image assets.
334+ *
335+ * @param {String|Object } tag A string specifying a tag that indicates which images to include or an object
336+ * which includes options and image URLs.
337+ * @param {Object } options Configuration options. If options are passed as the first parameter, this parameter
338+ * should be empty
339+ *
340+ * @returns {string }
341+ */
342+ exports . download_multi = function download_multi ( tag ) {
343+ var options = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
344+
345+ return utils . api_download_url ( "multi" , utils . build_multi_and_sprite_params ( tag , options ) , options ) ;
346+ } ;
347+
348+ /**
349+ * Creates either a single animated image (GIF, PNG or WebP), video (MP4 or WebM) or a single PDF from multiple image
350+ * assets.
351+ *
352+ * Each asset is included as a single frame of the resulting animated image/video, or a page of the PDF (sorted
353+ * alphabetically by their Public ID).
354+ *
355+ * @param {String|Object } tag A string specifying a tag that indicates which images to include or an object
356+ * which includes options and image URLs.
357+ * @param {Function } callback Callback function
358+ * @param {Object } options Configuration options. If options are passed as the first parameter, this parameter
359+ * should be empty
360+ *
361+ * @return {Object }
362+ */
308363exports . multi = function multi ( tag , callback ) {
309364 var options = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { } ;
310365
311366 return call_api ( "multi" , callback , options , function ( ) {
312- var transformation = utils . generate_transformation_string ( extend ( { } , options ) ) ;
313- return [ {
314- timestamp : utils . timestamp ( ) ,
315- tag : tag ,
316- transformation : transformation ,
317- format : options . format ,
318- async : options . async ,
319- notification_url : options . notification_url
320- } ] ;
367+ return [ utils . build_multi_and_sprite_params ( tag , options ) ] ;
321368 } ) ;
322369} ;
323370
0 commit comments