Handling of images (resolution changes to max 500px)

I’m playing around with a widget using images.
Images are downloaded from web-server. To reduce traffic, the images are stored locally on the device.
If the image is shown in widget it looks blurry. After some debugging, I recognized that resolution of the stored image was changed for whatever reason. And have no idea why.
Is there any mechanism in scriptable which goes in this direction?
I have the feeling that this preferably happens, in widget environment and not if code is started in the app itself.
The original images are up to 2000x600px. All reduced images have a max of 500x500px.

Result after debugging:

Images loaded with Request.loadImage(URL) are reduced to a max of 500x500px if called in widget environment.
Same call in app-environment leads to an image in original resolution (tested up to 2000x2000px)
In lot of cases 500x500px might be enough, even if it’s already blurry when shown in widget.
In my widget, I only want to show a part of an image, which makes resolution even worth.

Any idea how to persist original resolution in widget environment?

I’ve excluded all file-handling and downloads to raw data. It works. :slight_smile:

It seems, that there’s some memory issue in image handling.
In this script https://github.com/JoeGit42/DilbertWidget I play around with images.

It works fine on one phone (iPhone 8), but not on another one (iPhone 12 Pro).
The iPhone 12 is the phone I use to debug etc…

After some debugging (using text file in iCloud) it seems that function drawImageAtPoint() of DrawContext does not work with bigger images in all environments.
Script just terminates within this function.

It always works, when using scriptable app. But it does not work as widget.
If I force the image to be really small it works again. But I have to force it to a level far below other images which are working without any problem.
To mention again: Even bigger images work on other phone.

It seems that there is some kind of unpredictable memory issue.