@@ -394,10 +394,12 @@ def get_image_url(
394394 image : MediaItemImage ,
395395 size : int = 0 ,
396396 prefer_proxy : bool = False ,
397- image_format : str = "png" ,
397+ image_format : str | None = None ,
398398 prefer_stream_server : bool = False ,
399399 ) -> str :
400400 """Get (proxied) URL for MediaItemImage."""
401+ if image_format is None :
402+ image_format = "png" if image .path .lower ().endswith (".png" ) else "jpg"
401403 if not image .remotely_accessible or prefer_proxy or size :
402404 # return imageproxy url for images that need to be resolved
403405 # the original path is double encoded
@@ -417,11 +419,13 @@ async def get_thumbnail(
417419 provider : str ,
418420 size : int | None = None ,
419421 base64 : bool = False ,
420- image_format : str = "png" ,
422+ image_format : str | None = None ,
421423 ) -> bytes | str :
422424 """Get/create thumbnail image for path (image url or local path)."""
423425 if not self .mass .get_provider (provider ) and not path .startswith ("http" ):
424426 raise ProviderUnavailableError
427+ if image_format is None :
428+ image_format = "png" if path .lower ().endswith (".png" ) else "jpg"
425429 if provider == "builtin" and path .startswith ("/collage/" ):
426430 # special case for collage images
427431 path = os .path .join (self ._collage_images_dir , path .split ("/collage/" )[- 1 ])
@@ -441,7 +445,9 @@ async def handle_imageproxy(self, request: web.Request) -> web.Response:
441445 # temporary for backwards compatibility
442446 provider = "builtin"
443447 size = int (request .query .get ("size" , "0" ))
444- image_format = request .query .get ("fmt" , "png" )
448+ image_format = request .query .get ("fmt" , None )
449+ if image_format is None :
450+ image_format = "png" if path .lower ().endswith (".png" ) else "jpg"
445451 if not self .mass .get_provider (provider ) and not path .startswith ("http" ):
446452 return web .Response (status = 404 )
447453 if "%" in path :
0 commit comments