fixed size for videos unsupported by MediaMetadataRetriever but supported by metadata-extractor
This commit is contained in:
parent
d28ea44ff2
commit
be2c9ed914
2 changed files with 19 additions and 17 deletions
|
@ -122,17 +122,15 @@ class SourceImageEntry {
|
||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
fillVideoByMediaMetadataRetriever(context)
|
fillVideoByMediaMetadataRetriever(context)
|
||||||
if (isSized && hasDuration) return this
|
if (isSized && hasDuration) return this
|
||||||
}
|
fillByMetadataExtractor(context)
|
||||||
// skip metadata-extractor for raw images because it reports the decoded dimensions instead of the raw dimensions
|
} else {
|
||||||
if (!MimeTypes.isRaw(sourceMimeType) && MimeTypes.isSupportedByMetadataExtractor(sourceMimeType)) {
|
|
||||||
fillByMetadataExtractor(context)
|
fillByMetadataExtractor(context)
|
||||||
if (isSized && foundExif) return this
|
if (isSized && foundExif) return this
|
||||||
}
|
|
||||||
if (ExifInterface.isSupportedMimeType(sourceMimeType)) {
|
|
||||||
fillByExifInterface(context)
|
fillByExifInterface(context)
|
||||||
if (isSized) return this
|
|
||||||
}
|
}
|
||||||
fillByBitmapDecode(context)
|
if (!isSized) {
|
||||||
|
fillByBitmapDecode(context)
|
||||||
|
}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +154,9 @@ class SourceImageEntry {
|
||||||
|
|
||||||
// finds: width, height, orientation, date, duration
|
// finds: width, height, orientation, date, duration
|
||||||
private fun fillByMetadataExtractor(context: Context) {
|
private fun fillByMetadataExtractor(context: Context) {
|
||||||
|
// skip raw images because `metadata-extractor` reports the decoded dimensions instead of the raw dimensions
|
||||||
|
if (!MimeTypes.isSupportedByMetadataExtractor(sourceMimeType) || MimeTypes.isRaw(sourceMimeType)) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StorageUtils.openInputStream(context, uri)?.use { input ->
|
StorageUtils.openInputStream(context, uri)?.use { input ->
|
||||||
val metadata = ImageMetadataReader.readMetadata(input)
|
val metadata = ImageMetadataReader.readMetadata(input)
|
||||||
|
@ -206,6 +207,8 @@ class SourceImageEntry {
|
||||||
|
|
||||||
// finds: width, height, orientation, date
|
// finds: width, height, orientation, date
|
||||||
private fun fillByExifInterface(context: Context) {
|
private fun fillByExifInterface(context: Context) {
|
||||||
|
if (!ExifInterface.isSupportedMimeType(sourceMimeType)) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StorageUtils.openInputStream(context, uri)?.use { input ->
|
StorageUtils.openInputStream(context, uri)?.use { input ->
|
||||||
val exif = ExifInterface(input)
|
val exif = ExifInterface(input)
|
||||||
|
|
|
@ -98,16 +98,13 @@ class _ThumbnailRasterImageState extends State<ThumbnailRasterImage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (!entry.canDecode) {
|
if (!entry.canDecode) {
|
||||||
return ErrorThumbnail(
|
return _buildError(context, '${entry.mimeType} not supported', null);
|
||||||
entry: entry,
|
|
||||||
extent: extent,
|
|
||||||
tooltip: '${entry.mimeType} not supported',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final fastImage = Image(
|
final fastImage = Image(
|
||||||
key: ValueKey('LQ'),
|
key: ValueKey('LQ'),
|
||||||
image: _fastThumbnailProvider,
|
image: _fastThumbnailProvider,
|
||||||
|
errorBuilder: _buildError,
|
||||||
width: extent,
|
width: extent,
|
||||||
height: extent,
|
height: extent,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
|
@ -137,11 +134,7 @@ class _ThumbnailRasterImageState extends State<ThumbnailRasterImage> {
|
||||||
child: frame == null ? fastImage : child,
|
child: frame == null ? fastImage : child,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
errorBuilder: (context, error, stackTrace) => ErrorThumbnail(
|
errorBuilder: _buildError,
|
||||||
entry: entry,
|
|
||||||
extent: extent,
|
|
||||||
tooltip: error.toString(),
|
|
||||||
),
|
|
||||||
width: extent,
|
width: extent,
|
||||||
height: extent,
|
height: extent,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
|
@ -173,6 +166,12 @@ class _ThumbnailRasterImageState extends State<ThumbnailRasterImage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildError(BuildContext context, Object error, StackTrace stackTrace) => ErrorThumbnail(
|
||||||
|
entry: entry,
|
||||||
|
extent: extent,
|
||||||
|
tooltip: error.toString(),
|
||||||
|
);
|
||||||
|
|
||||||
// when the entry image itself changed (e.g. after rotation)
|
// when the entry image itself changed (e.g. after rotation)
|
||||||
void _onImageChanged() async {
|
void _onImageChanged() async {
|
||||||
// rebuild to refresh the thumbnails
|
// rebuild to refresh the thumbnails
|
||||||
|
|
Loading…
Reference in a new issue