放宽上传到50MB并取消分辨率限制
This commit is contained in:
parent
48deda49f7
commit
800017b78c
@ -4445,7 +4445,7 @@ export function AdminSettingsClient() {
|
||||
<p>• API地址应指向服务根地址,例如: https://techsz.aoscdn.com</p>
|
||||
<p>• 系统会自动调用 /api/tasks/visual/scale 接口进行变清晰处理</p>
|
||||
<p>• 支持的图片格式:JPG, JPEG, PNG, BMP, WEBP, TIFF等</p>
|
||||
<p>• 图片大小:不超过20MB,分辨率最大4096x4096</p>
|
||||
<p>• 图片大小:不超过50MB,不限制分辨率(建议按业务需求控制尺寸)</p>
|
||||
<p>• 返回的链接有效期为1小时,系统会自动下载并存储到S3</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -85,8 +85,8 @@ async function optimizeImage(buffer: Buffer, mimeType: string): Promise<Buffer>
|
||||
const FileSchema = z.object({
|
||||
file: z
|
||||
.instanceof(Blob)
|
||||
.refine((file) => file.size <= 20 * 1024 * 1024, {
|
||||
message: "File size should be less than 20MB",
|
||||
.refine((file) => file.size <= 50 * 1024 * 1024, {
|
||||
message: "File size should be less than 50MB",
|
||||
})
|
||||
// Update the file type based on the kind of files you want to accept
|
||||
.refine((file) => ["image/jpeg", "image/png", "image/webp"].includes(file.type), {
|
||||
|
||||
@ -932,8 +932,8 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.size > 20 * 1024 * 1024) {
|
||||
toast.error('图片大小不能超过 20MB');
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error('图片大小不能超过 50MB');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -283,8 +283,8 @@ export function CanvasWorkspace() {
|
||||
|
||||
for (let index = 0; index < files.length; index++) {
|
||||
const file = files[index];
|
||||
if (file.size > 20 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 20MB");
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 50MB");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -560,9 +560,9 @@ export function ImageNode({ node, isSelected }: ImageNodeProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证文件大小 (20MB)
|
||||
if (file.size > 20 * 1024 * 1024) {
|
||||
toast.error('图片大小不能超过 20MB');
|
||||
// 验证文件大小 (50MB)
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error('图片大小不能超过 50MB');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -105,8 +105,8 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod
|
||||
toast.error("请上传图片文件");
|
||||
return;
|
||||
}
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 10MB");
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 50MB");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -160,8 +160,8 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod
|
||||
const file = item.getAsFile();
|
||||
if (!file) continue;
|
||||
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 10MB");
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 50MB");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -303,8 +303,8 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod
|
||||
const handleImageUpload = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (file) {
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 10MB");
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 50MB");
|
||||
e.target.value = "";
|
||||
return;
|
||||
}
|
||||
@ -1763,7 +1763,7 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel, initialResizeMod
|
||||
</div>
|
||||
<h3 className="text-xl font-medium mb-2">上传图片以开始编辑</h3>
|
||||
<p className="text-muted-foreground mb-2">拖拽图片到此处、点击选择或 Ctrl+V 粘贴</p>
|
||||
<p className="text-muted-foreground/60 text-sm mb-6">支持 JPG, PNG, WebP 格式,最大 10MB</p>
|
||||
<p className="text-muted-foreground/60 text-sm mb-6">支持 JPG, PNG, WebP 格式,最大 50MB</p>
|
||||
<Button variant="default">选择图片</Button>
|
||||
<input
|
||||
type="file"
|
||||
|
||||
@ -239,7 +239,8 @@ function PureMultimodalInput({
|
||||
]);
|
||||
|
||||
// 压缩图片函数(保持原格式:JPG保持JPG,PNG保持PNG)
|
||||
const compressImage = useCallback(async (file: File, maxSizeMB = 8): Promise<File> => {
|
||||
// 不限制分辨率,优先保留原图质量
|
||||
const compressImage = useCallback(async (file: File, maxSizeMB = 50): Promise<File> => {
|
||||
// 如果不是图片,直接返回
|
||||
if (!file.type.startsWith('image/')) {
|
||||
return file;
|
||||
@ -265,14 +266,12 @@ function PureMultimodalInput({
|
||||
|
||||
img.onload = () => {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
const width = img.width;
|
||||
const height = img.height;
|
||||
const maxDimension = 4096; // 4K
|
||||
const width = img.width;
|
||||
const height = img.height;
|
||||
|
||||
// ✅ 免检通道:如果图片小于 5MB 且分辨率在 4K 以内,直接返回原图
|
||||
// 这样可以避免不必要的压缩导致的画质损失
|
||||
if (file.size <= 5 * 1024 * 1024 && width <= maxDimension && height <= maxDimension) {
|
||||
console.log(`[压缩] 免检通过: ${(file.size / 1024 / 1024).toFixed(2)}MB, ${width}x${height} (小于5MB且小于4K),使用原图`);
|
||||
// ✅ 免检通道:50MB以内直接使用原图,避免分辨率与画质损失
|
||||
if (file.size <= maxSizeMB * 1024 * 1024) {
|
||||
console.log(`[压缩] 免检通过: ${(file.size / 1024 / 1024).toFixed(2)}MB, ${width}x${height},使用原图`);
|
||||
resolve(file);
|
||||
return;
|
||||
}
|
||||
@ -281,17 +280,6 @@ function PureMultimodalInput({
|
||||
let newWidth = width;
|
||||
let newHeight = height;
|
||||
|
||||
// 计算缩放比例以达到目标大小
|
||||
if (newWidth > maxDimension || newHeight > maxDimension) {
|
||||
if (newWidth > newHeight) {
|
||||
newHeight = (newHeight / newWidth) * maxDimension;
|
||||
newWidth = maxDimension;
|
||||
} else {
|
||||
newWidth = (newWidth / newHeight) * maxDimension;
|
||||
newHeight = maxDimension;
|
||||
}
|
||||
}
|
||||
|
||||
canvas.width = newWidth;
|
||||
canvas.height = newHeight;
|
||||
|
||||
|
||||
@ -82,8 +82,8 @@ export function SceneFusionDialog({ open, onOpenChange }: SceneFusionDialogProps
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 10MB");
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 50MB");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,8 +107,8 @@ export function SceneFusionDialog({ open, onOpenChange }: SceneFusionDialogProps
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error(`图片 ${file.name} 大小不能超过 10MB`);
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error(`图片 ${file.name} 大小不能超过 50MB`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -138,8 +138,8 @@ export function SceneFusionView({ onBack, initialProductImage, initialProductNam
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 10MB");
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error("图片大小不能超过 50MB");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -177,8 +177,8 @@ export function SceneFusionView({ onBack, initialProductImage, initialProductNam
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
if (file.size > 10 * 1024 * 1024) {
|
||||
toast.error(`图片 ${file.name} 大小不能超过 10MB`);
|
||||
if (file.size > 50 * 1024 * 1024) {
|
||||
toast.error(`图片 ${file.name} 大小不能超过 50MB`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user