Let saved library stills queue Edit without a format rejection.
Use catalog width/height or aspect fallback in resolveRequestSize, restore GIF/BMP upload messaging, and keep Photo to change still ids across reload so Klein/Qwen Edit can bind imageAId. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -19,7 +19,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
const size = imageDimensions(image.data)
|
||||
if (!size) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Use a PNG, JPEG, or WebP' })
|
||||
throw createError({ statusCode: 400, statusMessage: 'Use a PNG, JPEG, WebP, GIF, or BMP image.' })
|
||||
}
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const library = publicLibrary(event)
|
||||
|
||||
@@ -7,7 +7,7 @@ export default defineEventHandler(async event => {
|
||||
const {owner}=assertLibraryOwner(event),folderId=field('folderId')
|
||||
assertFolderAccess(event,folderId)
|
||||
const size=imageDimensions(image.data)
|
||||
if (!size) throw createError({statusCode:400,statusMessage:'Use a PNG, JPEG, or WebP'})
|
||||
if (!size) throw createError({statusCode:400,statusMessage:'Use a PNG, JPEG, WebP, GIF, or BMP image.'})
|
||||
const filename=image.filename!.split(/[\\/]/).at(-1)!
|
||||
const still=await saveStill({ownerKey:owner,folderId,filename,name:filename.replace(/\.[^.]+$/,''),data:image.data,...size,hideInput:field('hideInput')==='true',role:'input'})
|
||||
if (!still?.id) throw createError({statusCode:400,statusMessage:'Could not save that image to the library.'})
|
||||
|
||||
@@ -32,18 +32,20 @@ export async function resolveRequestSize(owner: string, request: any) {
|
||||
const id = request.imageAId || request.identityStillId
|
||||
if (id) {
|
||||
const still = getStill(owner, id)
|
||||
const path = stillPath(owner, id)
|
||||
if (!existsSync(path)) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'That still is missing from the library' })
|
||||
}
|
||||
if (still.width && still.height) {
|
||||
dimensions = { width: still.width, height: still.height }
|
||||
// Catalog size wins — never re-probe a saved still as an upload format check.
|
||||
if (Number(still.width) > 0 && Number(still.height) > 0) {
|
||||
dimensions = { width: Number(still.width), height: Number(still.height) }
|
||||
} else {
|
||||
// Header only — never read the full archive PNG into memory on Generate click
|
||||
dimensions = imageDimensions(readImageHeader(path))
|
||||
}
|
||||
if (!dimensions) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Use a PNG, JPEG, or WebP' })
|
||||
const path = stillPath(owner, id)
|
||||
if (!existsSync(path)) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'That still is missing from the library' })
|
||||
}
|
||||
try {
|
||||
dimensions = imageDimensions(readImageHeader(path))
|
||||
} catch {
|
||||
dimensions = null
|
||||
}
|
||||
// Header probe failed — fall through to bench aspect via resolveSize.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user