avif: fixed decoding of rotated still, fixed sizing during cataloguing

info: show avif metadata via exifinterface
This commit is contained in:
Thibault Deckers 2024-11-17 18:18:40 +01:00
parent ad214b3f56
commit 039de32faa
2 changed files with 14 additions and 5 deletions

View file

@ -99,9 +99,12 @@ object MimeTypes {
else -> true
}
// as of `ExifInterface` v1.3.1, `isSupportedMimeType` reports
// no support for TIFF images, but it can actually open them (maybe other formats too)
fun canReadWithExifInterface(mimeType: String, strict: Boolean = true) = ExifInterface.isSupportedMimeType(mimeType) || !strict
// as of `ExifInterface` v1.4.0-alpha01, `isSupportedMimeType` reports
// no support for AVIF/TIFF images, but it can actually open them (maybe other formats too)
fun canReadWithExifInterface(mimeType: String, strict: Boolean = true): Boolean {
if (!strict) return true
return ExifInterface.isSupportedMimeType(mimeType) || mimeType == AVIF
}
// as of latest PixyMeta
fun canReadWithPixyMeta(mimeType: String) = when (mimeType) {
@ -143,7 +146,7 @@ object MimeTypes {
return if (pageId != null && MultiPageImage.isSupported(mimeType)) {
true
} else when (mimeType) {
DNG, DNG_ADOBE, HEIC, HEIF, PNG, WEBP -> true
AVIF, DNG, DNG_ADOBE, HEIC, HEIF, PNG, WEBP -> true
else -> false
}
}

View file

@ -33,8 +33,14 @@ extension ExtraAvesEntryCatalog on AvesEntry {
if ((isVideo && (!isSized || durationMillis == 0)) || mimeType == MimeTypes.avif) {
// exotic video that is not sized during loading
final fields = await VideoMetadataFormatter.getLoadingMetadata(this);
// check size as the video interpreter may fail on some AVIF stills
final width = fields['width'];
final height = fields['height'];
final isValid = (width == null || width > 0) && (height == null || height > 0);
if (isValid) {
await applyNewFields(fields, persist: persist);
}
}
// cataloguing on platform
catalogMetadata = await metadataFetchService.getCatalogMetadata(this, background: background);