mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
feat: no small local thumbnail (#17787)
* feat: no small local thumbnail * pr feedback
This commit is contained in:
parent
1de2eae12d
commit
13d6bd67b1
@ -42,42 +42,33 @@ class ImmichLocalThumbnailProvider
|
|||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
chunkEvents: chunkEvents.stream,
|
chunkEvents: chunkEvents.stream,
|
||||||
informationCollector: () sync* {
|
informationCollector: () sync* {
|
||||||
yield ErrorDescription(asset.fileName);
|
yield ErrorDescription(key.asset.fileName);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Streams in each stage of the image as we ask for it
|
// Streams in each stage of the image as we ask for it
|
||||||
Stream<ui.Codec> _codec(
|
Stream<ui.Codec> _codec(
|
||||||
Asset key,
|
Asset assetData,
|
||||||
ImageDecoderCallback decode,
|
ImageDecoderCallback decode,
|
||||||
StreamController<ImageChunkEvent> chunkEvents,
|
StreamController<ImageChunkEvent> chunkEvents,
|
||||||
) async* {
|
) async* {
|
||||||
// Load a small thumbnail
|
final thumbBytes = await assetData.local
|
||||||
final thumbBytes = await asset.local?.thumbnailDataWithSize(
|
?.thumbnailDataWithSize(ThumbnailSize(width, height));
|
||||||
const ThumbnailSize.square(32),
|
if (thumbBytes == null) {
|
||||||
quality: 75,
|
chunkEvents.close();
|
||||||
);
|
|
||||||
if (thumbBytes != null) {
|
|
||||||
final buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes);
|
|
||||||
final codec = await decode(buffer);
|
|
||||||
yield codec;
|
|
||||||
} else {
|
|
||||||
debugPrint("Loading thumb for ${asset.fileName} failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
final normalThumbBytes =
|
|
||||||
await asset.local?.thumbnailDataWithSize(ThumbnailSize(width, height));
|
|
||||||
if (normalThumbBytes == null) {
|
|
||||||
throw StateError(
|
throw StateError(
|
||||||
"Loading thumb for local photo ${asset.fileName} failed",
|
"Loading thumb for local photo ${asset.fileName} failed",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final buffer = await ui.ImmutableBuffer.fromUint8List(normalThumbBytes);
|
|
||||||
final codec = await decode(buffer);
|
|
||||||
yield codec;
|
|
||||||
|
|
||||||
chunkEvents.close();
|
try {
|
||||||
|
final buffer = await ui.ImmutableBuffer.fromUint8List(thumbBytes);
|
||||||
|
final codec = await decode(buffer);
|
||||||
|
yield codec;
|
||||||
|
} finally {
|
||||||
|
chunkEvents.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user