Thanks for the many responses. A Picture Object in Xojo consists of only pixel data—it is not inherently a JPEG, TIFF, or PNG. Trying to determine its format makes no sense because it does not retain any original file type information.
For those who may come across this discussion in the future, I think it’s worth explaining why I originally asked this question. My inquiry was based on a misconception, and clarifying it may help others understand the issue better and avoid the same trap.
I was initially interested in Base64 encoding as a way to embed images directly into my application (as Constants) instead of relying on linked external files. One of my concerns was the size of these Base64-encoded text files. After some research, I found that Base64 encoding increases the file size by about 35–40%, which isn’t too troublesome.
This led me to wonder whether using JPEG images for Base64 encoding was more efficient than using uncompressed images. I soon learned that it is generally better to encode JPEGs rather than raw image data when using Base64. You can reduce the amount of text. But just why?
At first, it seemed counterintuitive that a 200x200 pixel image displayed on a Canvas could be smaller in size as a JPEG compared to a Picture Object of a non-compressed image. After all, the number of pixels remains the same regardless of the format. This made me question whether Xojo’s Picture Object was somehow storing images in a JPEG format under certain conditions. That led me to search for a way to determine whether a given Picture Object was originally a JPEG — which, as it turns out, is not possible within Xojo and makes no sense.
[Parnell will be happy to know that ChatGPT confidently misled me on this topic, providing incorrect code for determining a Picture Object’s format.]
I was trying to determine whether a Picture Object was a JPEG, assuming that it somehow retained its original file format. While it’s true that a FolderItem (an actual file) contains metadata identifying it as a JPEG, this information is lost once the image is loaded into a Picture Object in Xojo.
I should have paid more attention when going the other direction, when generating Base64-encoded text from a Picture Object. The EncodeBase64 command requires explicitly specifying the desired format (PNG, JPEG, etc.). That alone should have made me question my worldview, why it was necessary? If the Picture Object already “knew” it was a JPEG, this step wouldn’t be needed.
The Base64 text itself represents either a JPEG, PNG, or another format, but this has nothing to do with the Picture Object itself. The Picture Object will always store raw pixel data, regardless of the file format of it originator. However, the Base64 text size created from EncodeBase64 can vary significantly based on how the encoding is specified.
If your goal is to minimize the size of Base64-encoded text, you should convert the Picture Object to JPEG as you are encoding it, as JPEG compression significantly reduces file size. Later, when decoding the Base64 text back into a Picture Object, the image will be reconstructed from the smaller data source — but this has nothing to do with how the original Picture Object was created (whether from a TIFF, PNG, or JPEG file).
In summary, a Picture Object’s size in memory depends basically on its pixel dimensions — not its original file format. However, the Base64 representation can be much smaller if the image is first converted to JPEG as it is transitioning to Base64 text.