NodeJS OpenAI API: Image Edit Error - PNG Format and Size Restrictions

I’m having trouble with the OpenAI Dall-e 2 image editing feature using the NodeJS SDK. My code looks like this:

const imageStream = fs.createReadStream(`./images/user_${userId}.png`)
const maskStream = fs.createReadStream(`./images/user_${userId}_mask.png`)

try {
  const result = await aiClient.images.edit({
    image: imageStream,
    mask: maskStream,
    prompt: userPrompt || 'Modify image based on prompt',
  })
} catch (error) {
  console.error('Error:', error.message)
}

But I’m getting a 400 error saying the image must be PNG and under 4MB. I’ve double-checked my files, and they meet these requirements. Any ideas what might be causing this? Could it be a problem with how I’m passing the image streams to the API? Thanks for any help!

hey there jackHero77, had similar issues before. make sure ur image dimensions are exactly square (like 1024x1024) and the color mode is RGB, not CMYK. also, try converting to base64 string instead of streams. that worked for me. good luck!