Runtime error in MedialOWindows.cpp

One of my users is getting an error loading a picture in my app:

I think this is a Xojo error because it’s not one of my dialogs. It looks as though the image is unable to be opened for some reason related to the orientation value.

I’d like to be able to handle this within my app so the user doesn’t see this dialog.

I’m currently opening the image like this:

dim image As Picture
try
  image = Picture.Open(imageFile)
catch
end

As I’ve wrapped this in a try/catch then I would have thought that the message the user is seeing would not appear. So that makes me think that the error might be in another part of the code that deals with the image. I also have this code because I need to convert the image to a memoryblock so I can pass it up to a web service:

'Create memory block
dim mb as MemoryBlock = image.GetData(Picture.FormatJPEG)

I also have this code to display a thumbnail image in the UI:

'Thumbnail image
dim thumbPicture as new Picture(100, 100)
thumbPicture.Graphics.DrawPictureInto image, false

(DrawPictureInto is an extension method that just calls DrawPicture on the Graphics object while maintaining the proportions)

I can wrap all of this code in try/catch statements to try to resolve this but it would be really helpful if somebody had seen this error before and could perhaps give me a tip on whether it is more likely to occur in Picture.Open or DrawPicture, etc?

Bad image file?
The orientation on a file should be a value between 1 and 8.

Thanks Christian and yes I assume it is a bad image file. My question is really about how can I trap for this to avoid the external error being shown and, instead, handle it within my own app.

please write a feedback report.
They should handle an undefined orientation (e.g. 0) or out of range orientation (>8) by ignoring it.

I’ve encountered the same “Runtime Error” popping up in a project that’s being compiled with Xojo 2016r3 when trying to load certain jpg images. It seems to be ignored with the most recent Xojo 2017/18 releases.
In the case of the Picture i’ve received, it seems to be a missing “dpi information”. Ignoring the “Runtime Error” loads the image just fine.
But of course, this Popup is not what i’d like to show to the customer using the app built with Xojo 2016r3.
So I wonder… is there a way to ignore the “failed assertion” in the XojoFramework?
A try - catch doesn’t make any difference. Maybe there’s some (undocumented) #pragma that would suppress/ignore this Popup shown by the XojoFramework?
Or are there other ways of loading a jpg from Disk (e.g. via Plugins, which don’t use the xojo-built-in framework)?

I found a workaround to prevent the Runtime Error: Common\\Win32\\MedialOWindows.cpp:384 - FailureCondition: PropertyTagTypeShort == propertyItems[i].type

The project previously used this code to open a FolderItem as Picture:

Dim aPicture As Picture = aFolderItem.OpenAsPicture()

or

Dim aPicture As Picture = Picture.Open(aFolderItem)

Both ways may result with the RuntimeError being shown (if a Picture with no/invalid DPI information is trying to be opened).

The workaround (which opens the file as Picture, but doesn’t show a Runtime Error) is:

Dim bs As BinaryStream = BinaryStream.Open(aFolderItem) Dim mb As MemoryBlock = bs.Read(bs.Length, nil) Dim aPicture As Picture = Picture.FromData(mb)
(shortened as example; omitting exception and error checking)