Well, I was unable to download the image created at the server-side, up today! So I move to download it as the binary json. Request is the same, setting ‘response_format’ as ‘b64_json’.
Depending on the language you are working it will be very different ways to convert from to a png bitmap image.
I am working in Swift version for Mac OS but I already have one done with Delphi to run my Android app, which nowadays using Delphi seems like not so common. For the sake of understanding my lib wrapper does such simple way to retrieve the files:
function TImages.DecodeJsonToFile(const Path: String): TArray<String>;
var
i: integer;
DecodedImage: TDecodedImage;
ListDecodedImage: TArray<TDecodedImage>;
begin
ListDecodedImage := ExtractImageMeta();
SetLength(Result, Length(ListDecodedImage));
i := 0;
for DecodedImage in ListDecodedImage do
begin
Result[i] := Path + DecodedImage.FileName;
DecodeToFile(DecodedImage.B64Json, Path + DecodedImage.FileName);
inc(i);
end;
end;
- The ExtractImageMeta() function will get the name of files into an array, as you could had request more than 1 image to be generated.
- We loop the image array and decode file, storing the image in a path
- The function returns a full path name of all the images which were downloaded and decoded
As I stated the way to decode will be depended in which language you are using, but surely today maybe all the languages can easily decode 64 bit string into binary.