guess image formats
Objective
provide an option to use image::guess_format to determine the image format, and make it the default.
useful when loading images of unknown format (eg from urls without extension/mimetype), and more robust when loading mislabelled files.
4. On some level I'd like to check and warn if the extension does not match the inferred type. However I'm not sure if this is the right spot for it: it will slow down loading in the happy path.
we could do that here, i don't think the perf impact would be noticeable (when compared to loading the binary data, converting internally, pushing it to gpu, etc) .
if so i'd like to add another extension (say .image) which would never trigger the warning. i'm downloading files with no extension where all i know is that they are images, so i have to hack some recognised extension onto the "path" (which is acually a urn plus base url encoded into a path) to get the loader to pick up the asset, and the warning would be noisy and useless for me in that case.
@robtfm that makes sense! Let's add that check and this special extension type here.
so i have to hack some recognised extension onto the "path"
That is still necessary after #10153?
That is still necessary after #10153?
Nice, I hadn’t seen that - I’ll check there’s no issues with using extensionless and then remove the “.image” extension
Since there are multiple asset loaders registered which can handle an extensionless path for an
Image. But that's beyond the scope for this PR.
right ... the built-in ones could probably be unified, but users might want to register other image loaders. i guess we may want a "default" loader for a given asset type (or possibly to try all the loaders?), but for now i'll leave the magic extension.
edit: probably asset_server.load_with::<ImageLoader>("bevy_bird") would be easiest.
@robtfm once merge conflicts are resolved I'll merge this in for you.
@robtfm I'll merge this ASAP once merge conflicts are fixed.
Completed in #13575