fix(transcode): update WEBP_MAX_DIMENSION to 7680

This commit is contained in:
yiling
2026-06-09 11:20:41 +08:00
parent d34c978c43
commit 6fc754838b
3 changed files with 12 additions and 10 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ describe('TranscodeService', () => {
expect(sharp).toHaveBeenCalledWith('input.png', { limitInputPixels: false })
const mockSharp = vi.mocked(sharp).mock.results[0].value
expect(mockSharp.resize).toHaveBeenCalledWith(480, 16383, expect.any(Object))
expect(mockSharp.resize).toHaveBeenCalledWith(480, 7680, expect.any(Object))
expect(mockSharp.webp).toHaveBeenCalledWith({ quality: 80 })
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
})
@@ -176,7 +176,7 @@ describe('TranscodeService', () => {
expect(sharp).toHaveBeenCalledWith(inputBuffer, { limitInputPixels: false })
const mockSharp = vi.mocked(sharp).mock.results[vi.mocked(sharp).mock.results.length - 1].value
expect(mockSharp.resize).toHaveBeenCalledWith(480, 16383, expect.any(Object))
expect(mockSharp.resize).toHaveBeenCalledWith(480, 7680, expect.any(Object))
expect(mockSharp.webp).toHaveBeenCalledWith({ quality: 80 })
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
})
+4 -5
View File
@@ -1,14 +1,13 @@
import { prisma } from '@shumai/db'
import { WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
import { s3Service } from '@shumai/core/src/s3/s3'
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
import '@shumai/db/src/prisma-json-types'
import { execFile } from 'child_process'
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import sharp from 'sharp'
import { promisify } from 'util'
import { s3Service } from '@shumai/core/src/s3/s3'
import { ulid } from 'ulid'
import { promisify } from 'util'
const execFileAsync = promisify(execFile)
@@ -291,7 +290,7 @@ export class TranscodeService {
const sharpInstance = sharp(input, { limitInputPixels: false })
const WEBP_MAX_DIMENSION = 16383
const WEBP_MAX_DIMENSION = 7680
const targetW = width > 0 ? Math.min(width, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
const targetH = height && height > 0 ? Math.min(height, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION