Picture.Open Supported Formats?

The documentation states for Picture.Save these supported file format:

Bout for Open: nada.

I can say .webpfiles are opened and displayed on macOS, but what about other platform(s) ?.

You could using the Picture.IsImportFormatSupported function to find out.

Given that the function accepts the same Enum as the Save function, I think you can use the same list you posted as the likely answer.

If you feel the documentation is not clear enough, please create an issue.

Hope that helps.

It certainly looks like it could use work.
Why on earth popup a file select dialog for JPEG files, allow the use to select one, and AFTERWARDS check whether the format is supported?

Var picFile As FolderItem
picFile = FolderItem.ShowOpenFileDialog("image/jpeg")
If Picture.IsImportFormatSupported(Picture.Formats.JPEG) Then

Surely you would do this:


Var picFile As FolderItem
If Picture.IsImportFormatSupported(Picture.Formats.JPEG) Then
picFile = FolderItem.ShowOpenFileDialog("image/jpeg")
else
picFile = FolderItem.ShowOpenFileDialog("image/png")
end if
1 Like

Thanks folks, you are correct.

@Martin T: time to modify the documentation. (Picture.Open)

Where is that done?

In the documentation example for IsImportFormatSupported

I had asked a similar question just a few weeks ago: Supported graphics file formats and got a comprehensive answer for macOS. The problem is that the support of graphics file formats largely depends on the operating system.

1 Like

And not a word in the docs.

Martin !

Ah, yes :sweat_smile:

While we are at it, the docs could also explain how color spaces are handled. It looks like under macOS the color space embedded in an image is indeed respected (thanks for that!), but when opening a graphics file it gets transformed into some generic RGB color space. Which one is it? It would certainly be nice if we could transform between color spaces, and embed the chosen color space when saving the image.

I’m not sure whether Xojo’s color space awareness is limited to macOS; are color spaces respected under Windows and Linux as well?

Once you open it as a Picture, it knows nothing of image format, compression or color space. If you care about those, you need to use a third party plugin.

That’s What I Want.

No need further things… here, I will save them as .png.

1 Like

Color profile management is a deep dark hole you can fall down very easily. I have been playing/fighting with it for almost 20 years. Generally xojo will open pictures into gRGB on macOS, for Windows, I assume sRGB, based on embedded resources loading and being rendered.
Open Picture will be using the built-in libraries on macOS, not sure what is used by Xojo on Windows.

We use MBS functions to convert between color profiles and save as a working copy in sRGB. macOS works best drawing all loaded images in gRGB while windows needs to be in the color profile of the monitor. So two monitors, two different profiles. macOS automatically does this for you.
MBS has functions to find and load those monitor color profiles.

Using plugins to open jpgs etc you can find the embedded color profile, eg adobe 1998 and then can convert into gRGB / sRGB yourself for rendering. Saving can be done with plugins to embed color profile.

While you can get very close it is hard to match other apps like Photoshop perfectly as they have their own color engines. You don’t have access to all the same adjustments so black point and temp cannot be tweaked, at least from what I could see many years ago.

Windows has LCMS and WCS, and MBS have classes to use both of these. macOS uses CSProfile to manage colors.

TLDR; PictureOpen = gRGB on macOS, sRGB in Windows. Use MBS to load/Save images, find the embedded color profile, and convert to required output colorspace.

1 Like

Thank you @Martin_T

Obviously I, and some others, missed that :face_with_monocle:

Nothing was missed. This is a vague description, not a part of a decent Language Reference.

And as Scott C says: IsImportFormatSupported. If you forget about it or are newbie, chances are you do not use it.

A simple See Also or whatever (two lines ?) is welcome.

One can dream to get:


in fact a complete list, but with this kind of presentation: clear.

In the current project, I only need to know what format can be opened withing Windows, and guess what ? I do not have a Windows machine handly.

Thus the question. But that question have to have a satisfactory answer for all Xojo users; Please do not follow the fashion to say: test by yourself. Of course, sometimes in the future I will test by myself, but this is a time waster for each user.