export default { /** * Indicates if output the original image instead of the compressed one * when the size of the compressed image is greater than the original one's * @type {boolean} */ strict: true, /** * Indicates if read the image's Exif Orientation information, * and then rotate or flip the image automatically. * @type {boolean} */ checkOrientation: true, /** * Indicates if retain the image's Exif information after compressed. * @type {boolean} */ retainExif: false, /** * The max width of the output image. * @type {number} */ maxWidth: Infinity, /** * The max height of the output image. * @type {number} */ maxHeight: Infinity, /** * The min width of the output image. * @type {number} */ minWidth: 0, /** * The min height of the output image. * @type {number} */ minHeight: 0, /** * The width of the output image. * If not specified, the natural width of the source image will be used. * @type {number} */ width: undefined, /** * The height of the output image. * If not specified, the natural height of the source image will be used. * @type {number} */ height: undefined, /** * Sets how the size of the image should be resized to the container * specified by the `width` and `height` options. * @type {string} */ resize: 'none', /** * The quality of the output image. * It must be a number between `0` and `1`, * and only available for `image/jpeg` and `image/webp` images. * Check out {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob canvas.toBlob}. * @type {number} */ quality: 0.8, /** * The mime type of the output image. * By default, the original mime type of the source image file will be used. * @type {string} */ mimeType: 'auto', /** * Files whose file type is included in this list, * and whose file size exceeds the `convertSize` value will be converted to JPEGs. * @type {string|Array} */ convertTypes: ['image/png'], /** * PNG files over this size (5 MB by default) will be converted to JPEGs. * To disable this, just set the value to `Infinity`. * @type {number} */ convertSize: 5000000, /** * The hook function to execute before draw the image into the canvas for compression. * @type {Function} * @param {CanvasRenderingContext2D} context - The 2d rendering context of the canvas. * @param {HTMLCanvasElement} canvas - The canvas for compression. * @example * function (context, canvas) { * context.fillStyle = '#fff'; * } */ beforeDraw: null, /** * The hook function to execute after drew the image into the canvas for compression. * @type {Function} * @param {CanvasRenderingContext2D} context - The 2d rendering context of the canvas. * @param {HTMLCanvasElement} canvas - The canvas for compression. * @example * function (context, canvas) { * context.filter = 'grayscale(100%)'; * } */ drew: null, /** * The hook function to execute when success to compress the image. * @type {Function} * @param {File} file - The compressed image File object. * @example * function (file) { * console.log(file); * } */ success: null, /** * The hook function to execute when fail to compress the image. * @type {Function} * @param {Error} err - An Error object. * @example * function (err) { * console.log(err.message); * } */ error: null, };