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 rotation
* @param fileName
* @param maxSize
* @returns blob url
*/
function getCroppedImg(
image: HTMLImageElement,
crop: Area,
rotation = 0,
fileName = 'newFile.jpeg'
fileName = 'newFile.jpeg',
maxSize = Infinity
): Promise<string> {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
if (!_isNil(ctx)) {
// 设定最大尺寸,可以提出来作为参数传入
const maxSize = 256;
// 计算最大尺寸
const size = Math.min(crop.width, crop.height, maxSize);

Loading…
Cancel
Save