feat: allow reference images for AI layer edits and relax stylistic constraints to allow for realism
Build and Deploy / build-and-push (push) Successful in 2m9s
Build and Deploy / build-and-push (push) Successful in 2m9s
This commit is contained in:
+10
-2
@@ -80,7 +80,7 @@ export async function pollStatus<T>(
|
||||
throw new Error("Polling timeout exceeded.");
|
||||
}
|
||||
|
||||
export async function editUVLayer(prompt: string, imageBase64: string, token: string): Promise<string> {
|
||||
export async function editUVLayer(prompt: string, imageBase64: string, token: string, referenceImageBase64?: string): Promise<string> {
|
||||
// Extract mime type if present in the data URI
|
||||
let mimeType = 'image/png';
|
||||
if (imageBase64.startsWith('data:')) {
|
||||
@@ -90,13 +90,21 @@ export async function editUVLayer(prompt: string, imageBase64: string, token: st
|
||||
}
|
||||
}
|
||||
|
||||
let referenceMimeType;
|
||||
if (referenceImageBase64 && referenceImageBase64.startsWith('data:')) {
|
||||
const match = referenceImageBase64.match(/^data:([^;]+);/);
|
||||
if (match) {
|
||||
referenceMimeType = match[1];
|
||||
}
|
||||
}
|
||||
|
||||
const response = await fetch('/api/sparkplug/edit-layer', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({ prompt, imageBase64, mimeType })
|
||||
body: JSON.stringify({ prompt, imageBase64, mimeType, referenceImageBase64, referenceMimeType })
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user