response = openai.Image.create_edit( image=open("sunlit_lounge.png", "rb"), mask=open("mask.png", "rb"), prompt="A sunlit indoor lounge area with a pool containing a flamingo", n=1, size="1024x1024")image_url = response['data'][0]['url']
// This is the Buffer object that contains your image dataconstbuffer= [your image data];// Set a `name` that ends with .png so that the API knows it's a PNG imagebuffer.name ="image.png";constresponse=awaitopenai.createImageVariation( buffer,1,"1024x1024");
// Cast the ReadStream to `any` to appease the TypeScript compilerconstresponse=awaitopenai.createImageVariation(fs.createReadStream("image.png") asany,1,"1024x1024");
这里有一个类似的例子,用于内存中的图像数据:
// This is the Buffer object that contains your image dataconstbuffer:Buffer= [your image data];// Cast the buffer to `any` so that we can set the `name` propertyconstfile:any= buffer;// Set a `name` that ends with .png so that the API knows it's a PNG imagefile.name ="image.png";constresponse=awaitopenai.createImageVariation( file,1,"1024x1024");