fix: maxSize 作为参数

pull/199/head
youxia 3 years ago
parent 87bb0e3b79
commit 4d9aa7248f

@ -73,21 +73,20 @@ let fileUrlTemp: string | null = null; // 缓存裁剪后的图片url
* @param crop * @param crop
* @param rotation * @param rotation
* @param fileName * @param fileName
* @param maxSize
* @returns blob url * @returns blob url
*/ */
function getCroppedImg( function getCroppedImg(
image: HTMLImageElement, image: HTMLImageElement,
crop: Area, crop: Area,
rotation = 0, rotation = 0,
fileName = 'newFile.jpeg' fileName = 'newFile.jpeg',
maxSize = Infinity
): Promise<string> { ): Promise<string> {
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
if (!_isNil(ctx)) { if (!_isNil(ctx)) {
// 设定最大尺寸,可以提出来作为参数传入
const maxSize = 256;
// 计算最大尺寸 // 计算最大尺寸
const size = Math.min(crop.width, crop.height, maxSize); const size = Math.min(crop.width, crop.height, maxSize);

Loading…
Cancel
Save