Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/UsingDALLEToGenerateImages.mlx
Binary file not shown.
14 changes: 12 additions & 2 deletions openAIImages.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -357,4 +357,14 @@ function mustBeValidFileType(filePath)
function mustBeNonzeroLengthTextScalar(content)
mustBeNonzeroLengthText(content)
mustBeTextScalar(content)
end
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