I have an image that I'm retrieving from an AWS S3 bucket and then passing to the Dall E/OpenAI API. When I attempt I get this error response:
message: "Invalid input image - format must be in ['RGBA', 'LA', 'L'], got RGB.",
I understand that RGB (the image file type I'm trying to upload) contains an alpha channel, which essentially means transparent areas on the image. Is it possible/easy to validate image types in NodeJS to catch bad images before I send them to the API?
My S3 gets a .png file like this:
const data = await s3Client.send(
new GetObjectCommand({
...bucketParams, // Bucket: <bucket name>
Key: `public/dalle/${inputParams.Key}`,
})
);
And then I pass that to the API via the openai library:
const response = await openai.createImageEdit(
data.Body as unknown as File,
(maskImageBuffer as unknown as File) || data.Body,
prompt,
1,
"256x256"
);