| | |
| | | return parseImageDimensions(bytes); |
| | | } catch (error) { |
| | | console.warn('解析图片尺寸失败:', error); |
| | | return { width: 600, height: 400 }; |
| | | return { width: 550, height: 400 }; |
| | | } |
| | | } |
| | | |
| | | function parseImageDimensions(bytes) { |
| | | if (bytes.length < 8) { |
| | | return { width: 600, height: 400 }; |
| | | return { width: 550, height: 400 }; |
| | | } |
| | | |
| | | // 检查 PNG 格式 (89 50 4E 47 0D 0A 1A 0A) |
| | |
| | | return parseJPEGDimensions(bytes); |
| | | } |
| | | |
| | | return { width: 600, height: 400 }; |
| | | return { width: 550, height: 400 }; |
| | | } |
| | | |
| | | // 解析 PNG 尺寸 |
| | |
| | | const height = view.getUint32(20, false); |
| | | return { width, height }; |
| | | } |
| | | return { width: 600, height: 400 }; |
| | | return { width: 550, height: 400 }; |
| | | } |
| | | |
| | | // 解析 JPEG 尺寸 |
| | |
| | | } |
| | | } |
| | | |
| | | return { width: 600, height: 400 }; |
| | | return { width: 550, height: 400 }; |
| | | } |
| | | |
| | | const imageOptions = { |
| | |
| | | getSize(img, tagValue, tagName, context) { |
| | | const dimensions = getDimensionsFromBase64Sync(tagValue); |
| | | const { width, height } = dimensions; |
| | | const targetWidth = 600; |
| | | const targetWidth = 550; |
| | | const scale = targetWidth / width; |
| | | let targetHeight = height * scale; |
| | | targetHeight = Math.max(100, Math.min(700, targetHeight)); |
| | | targetHeight = Math.max(100, Math.min(800, targetHeight)); |
| | | return [targetWidth, Math.round(targetHeight)]; |
| | | }, |
| | | }; |