I import Orhanerday\OpenAi library to my DALL-E Examples project but when I provide images, I got Invalid input image - format must be in ['RGBA'], got RGB.
error. I search for this error on the internet but I got nothing.
My code looks like
<?php
require __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework.
use Orhanerday\OpenAi\OpenAi;
$open_ai_key = getenv("OPENAIKEY");
$open_ai = new OpenAi($open_ai_key);
$otter = curl_file_create("C:\Users\dotor\OneDrive\Desktop\dalle-examples\otter.png");
$mask = curl_file_create("C:\Users\dotor\OneDrive\Desktop\dalle-examples\mask.png");
$result = $open_ai->imageEdit([
"image" => $otter,
"mask" => $mask,
"prompt" => "A cute baby sea otter wearing a beret",
"n" => 2,
"size" => "256x256",
]);
var_dump($result);
Png files;
I need to get a result without any errors, what is an RGBA png file and how can I provide?
The A in RGBA stands for Alpha, which is simply a value for opacity. Since this is the type needed for OpenAI, you should convert the plain RGB to RGBA leveraging an existing library. In python, I used the Python Image Library (PIL) convert function to complete this task.