VulpesOS/gaia/apps/camera/js/lib/create-thumbnail-image.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

35 lines
939 B
JavaScript
Executable file

define(function(require, exports, module) {
'use strict';
var cropResizeRotate = require('cropResizeRotate');
/**
* Create a thumbnail size canvas,
* copy the <img> or <video> into it
* cropping the edges as needed to
* make it fit, and then extract the
* thumbnail image as a blob and pass
* it to the callback.
*
* @param {Blob} imageBlob [description]
* @param {Object} metadata [description]
* @param {Object} thumbnailSize [description]
* @param {Function} done [description]
*/
module.exports = function(imageBlob, metadata, thumbnailSize, done) {
cropResizeRotate(imageBlob, null, thumbnailSize, null, metadata,
function(error, resizedBlob) {
// If we couldn't resize or rotate it, use the original
if (error) {
console.error('Error while resizing image: ' + error);
done(imageBlob);
return;
}
done(resizedBlob);
}
);
};
});