AI智能填充这个fun非常有争议,以为是AI扩图,点了一下发现没有请求api,也没有s_key。看了下函数,还是换个名称吧。。。 [HTML] 纯文本查看 复制代码 function processSingleImage(img){ var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var canvasWidth, canvasHeight; if(selectedSize === '6inch'){ if(imageOrientation === 'landscape'){ canvasWidth = 1800; canvasHeight = 1200; }else{ canvasWidth = 1200; canvasHeight = 1800; } }else if(selectedSize === 'a4'){ var dpi = 300; if(imageOrientation === 'landscape'){ canvasWidth = Math.round(297 / 25.4 * dpi); canvasHeight = Math.round(210 / 25.4 * dpi); }else{ canvasWidth = Math.round(210 / 25.4 * dpi); canvasHeight = Math.round(297 / 25.4 * dpi); } }else if(selectedSize === '1inch'){ canvasWidth = 295; canvasHeight = 413; }else if(selectedSize === '2inch'){ canvasWidth = 413; canvasHeight = 626; } canvas.width = canvasWidth; canvas.height = canvasHeight; var activeType = document.querySelector('.fill-preview-item.active').getAttribute('data-type'); if(activeType === 'blur'){ ctx.filter = 'blur(15px)'; ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight); ctx.filter = 'none'; drawImageCentered(ctx, img, canvasWidth, canvasHeight); }else{ var imageInfo = drawImageCentered(ctx, img, canvasWidth, canvasHeight); if(activeType === 'smart'){ extendEdgesOptimized(ctx, imageInfo, canvasWidth, canvasHeight); }else if(activeType === 'texture'){ applyTextureOptimized(ctx, imageInfo, canvasWidth, canvasHeight); } } return canvas.toDataURL('image/png'); } function applyAIFill(){ processedImageData = processSingleImage(currentImage); previewImage.src = processedImageData; }