diff --git a/examples/UsingDALLEToGenerateImages.mlx b/examples/UsingDALLEToGenerateImages.mlx index f0ce158..5c04990 100644 Binary files a/examples/UsingDALLEToGenerateImages.mlx and b/examples/UsingDALLEToGenerateImages.mlx differ diff --git a/openAIImages.m b/openAIImages.m index 479c60a..5be8139 100644 --- a/openAIImages.m +++ b/openAIImages.m @@ -298,7 +298,7 @@ function mustBeValidSize(this, imagesize) % Output the images if isfield(response.Body.Data.data,"url") urls = arrayfun(@(x) string(x.url), response.Body.Data.data); - images = arrayfun(@imread,urls,UniformOutput=false); + images = arrayfun(@myImread,urls,UniformOutput=false); else images = []; end @@ -357,4 +357,14 @@ function mustBeValidFileType(filePath) function mustBeNonzeroLengthTextScalar(content) mustBeNonzeroLengthText(content) mustBeTextScalar(content) -end \ No newline at end of file +end + +function data = myImread(URI) + % imread usually, but not always, fails to read from the + % https://oaidalleapiprodscus.blob.core.windows.net URLs returned by + % DALL•E. Use websave instead. + filename = tempname + ".png"; + clean = onCleanup(@() delete(filename)); + websave(filename,URI); + data = imread(filename); +end