diff --git a/flutter_cache_manager/CHANGELOG.md b/flutter_cache_manager/CHANGELOG.md index 17cf8c85..f1d60241 100644 --- a/flutter_cache_manager/CHANGELOG.md +++ b/flutter_cache_manager/CHANGELOG.md @@ -1,3 +1,11 @@ +## [3.5.0] - 2026-11-04 + +* **DEPRECATION** Deprecates `supportedFileNames`: whether an image is resized is now decided by the image engine from the file's content instead of from the file extension derived from the `Content-Type` header of the response ([#475](https://github.com/Baseflow/flutter_cache_manager/pull/475)) +* Resizes every format the engine can decode, including webp and bmp ([#353](https://github.com/Baseflow/flutter_cache_manager/issues/353)), and images served with a generic `Content-Type` such as `application/octet-stream`; files that are not images are returned untouched +* Passes animated images (gif, apng, animated webp) through untouched, since the resized image is always encoded as png and would lose its animation +* Stores resized images with a `.png` extension, matching the encoding that is used, instead of reusing the extension derived from the `Content-Type` header +* Returns the original file with a warning log through `cacheLogger` when an image cannot be decoded or resized, instead of erroring the stream. This reverses the decode error propagation introduced in 3.4.5 for [#400](https://github.com/Baseflow/flutter_cache_manager/issues/400) + ## [3.4.8] - 2026-11-02 * Uses the URL's file extension when a download's content type is missing or generic, such as `application/octet-stream` or `binary/octet-stream` ([#489](https://github.com/Baseflow/flutter_cache_manager/issues/489)). diff --git a/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart index 5851a7ab..858ad146 100644 --- a/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart @@ -3,10 +3,22 @@ import 'dart:math'; import 'dart:ui' as ui; import 'package:file/file.dart'; -import 'package:flutter/widgets.dart'; +import 'package:file/local.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; +/// Formats that used to be recognized by the extension of the file. +/// +/// Whether a file can be resized is now decided by the image engine, based on +/// the content of the file, so this list no longer reflects which files are +/// resized. It is kept only for backwards compatibility. +@Deprecated( + 'Image formats are detected from the file content instead of the file ' + 'extension. This list is no longer used and will be removed in a future ' + 'version.', +) const supportedFileNames = ['jpg', 'jpeg', 'png', 'tga', 'cur', 'ico']; + mixin ImageCacheManager on BaseCacheManager { /// Returns a resized image file to fit within maxHeight and maxWidth. It /// tries to keep the aspect ratio. It stores the resized image by adding @@ -67,60 +79,15 @@ mixin ImageCacheManager on BaseCacheManager { final Map> _runningResizes = {}; - Future _resizeImageFile( - FileInfo originalFile, - String key, - int? maxWidth, - int? maxHeight, - ) async { - final originalFileName = originalFile.file.path; - final fileExtension = originalFileName.split('.').last; - if (!supportedFileNames.contains(fileExtension)) { - return originalFile; - } - - final image = await _decodeImage(originalFile.file); - - final shouldResize = maxWidth != null - ? image.width > maxWidth - : false || maxHeight != null - ? image.height > maxHeight - : false; - if (!shouldResize) return originalFile; - if (maxWidth != null && maxHeight != null) { - final resizeFactorWidth = image.width / maxWidth; - final resizeFactorHeight = image.height / maxHeight; - final resizeFactor = max(resizeFactorHeight, resizeFactorWidth); - - maxWidth = (image.width / resizeFactor).round(); - maxHeight = (image.height / resizeFactor).round(); - } - - final resized = await _decodeImage( - originalFile.file, - width: maxWidth, - height: maxHeight, - ); - final resizedFile = (await resized.toByteData( - format: ui.ImageByteFormat.png, - ))!.buffer.asUint8List(); - final maxAge = originalFile.validTill.difference(DateTime.now()); - - final file = await putFile( - originalFile.originalUrl, - resizedFile, - key: key, - maxAge: maxAge, - fileExtension: fileExtension, - ); - - return FileInfo( - file, - originalFile.source, - originalFile.validTill, - originalFile.originalUrl, - ); - } + /// Keys whose original file is known not to be resizable: it is not an + /// image the engine can decode, it is animated, or it already fits within + /// the requested size. Probing a file reads it and decodes a frame, so the + /// outcome is remembered to avoid repeating that work on every call. + /// + /// The entries are not invalidated when the original file is re-downloaded + /// with different content; they are reset when a resize does succeed or + /// when the manager instance is recreated. + final Set _notResizableKeys = {}; Stream _fetchedResizedFile( String url, @@ -141,49 +108,191 @@ mixin ImageCacheManager on BaseCacheManager { yield response; } if (response is FileInfo) { - yield await _resizeImageFile(response, resizedKey, maxWidth, maxHeight); + if (_notResizableKeys.contains(resizedKey)) { + yield response; + } else { + yield await _resizeImageFile( + response, + resizedKey, + maxWidth: maxWidth, + maxHeight: maxHeight, + ); + } } } } + + Future _resizeImageFile( + FileInfo originalFile, + String resizedKey, { + int? maxWidth, + int? maxHeight, + }) async { + final file = originalFile.file; + final probe = await _probeImage(file); + if (probe == null) { + return _notResizable(originalFile, resizedKey); + } + final (descriptor, frameCount, imageWidth, imageHeight) = probe; + + // Resizing re-encodes the image as png, which keeps a single frame, so + // animated images (gif, apng, animated webp, ...) are passed through + // untouched. + if (frameCount > 1) { + descriptor.dispose(); + return _notResizable(originalFile, resizedKey); + } + + final shouldResize = + (maxWidth != null && imageWidth > maxWidth) || + (maxHeight != null && imageHeight > maxHeight); + if (!shouldResize) { + descriptor.dispose(); + return _notResizable(originalFile, resizedKey); + } + + if (maxWidth != null && maxHeight != null) { + final resizeFactorWidth = imageWidth / maxWidth; + final resizeFactorHeight = imageHeight / maxHeight; + final resizeFactor = max(resizeFactorHeight, resizeFactorWidth); + + maxWidth = (imageWidth / resizeFactor).round(); + maxHeight = (imageHeight / resizeFactor).round(); + } + + try { + final resizedFile = await _decodeResized( + descriptor, + width: maxWidth, + height: maxHeight, + ); + final maxAge = originalFile.validTill.difference(DateTime.now()); + + final resized = await putFile( + originalFile.originalUrl, + resizedFile, + key: resizedKey, + maxAge: maxAge, + // The resized image is always encoded as png, so it is stored with a + // png extension. The extension of the original file cannot be reused: + // it comes from the Content-Type header of the response, which can be + // something generic like `application/octet-stream` instead of the + // format the image is actually encoded in. + fileExtension: 'png', + ); + + _notResizableKeys.remove(resizedKey); + return FileInfo( + resized, + originalFile.source, + originalFile.validTill, + originalFile.originalUrl, + ); + } on Object catch (error) { + _logResizeWarning(file, error); + return _notResizable(originalFile, resizedKey); + } finally { + descriptor.dispose(); + } + } + + /// Remembers that the file of [originalFile] does not need to be probed + /// again for [resizedKey] and returns it untouched. + FileInfo _notResizable(FileInfo originalFile, String resizedKey) { + if (_notResizableKeys.length > 512) _notResizableKeys.clear(); + _notResizableKeys.add(resizedKey); + return originalFile; + } +} + +/// Probes [file] with the image engine. +/// +/// Returns the encoded image descriptor together with its frame count and +/// size, or `null` when the engine cannot decode the file. Whether a file is +/// a resizable image is decided entirely by the engine: it knows every format +/// Flutter can decode, including platform specific ones like heif, so there +/// is no list of signatures or extensions to maintain. +/// +/// The returned descriptor is not disposed and has to be disposed by the +/// caller; it can be used to decode a resized frame without reading the file +/// again. When `null` is returned everything is cleaned up here. +Future<(ui.ImageDescriptor, int frameCount, int width, int height)?> +_probeImage(File file) async { + ui.ImmutableBuffer? buffer; + ui.ImageDescriptor? descriptor; + ui.Codec? codec; + try { + buffer = await _bufferFor(file); + descriptor = await ui.ImageDescriptor.encoded(buffer); + codec = await descriptor.instantiateCodec(); + final frameCount = codec.frameCount; + int width; + int height; + if (kIsWeb) { + // `descriptor.width` and `descriptor.height` are not supported on web + // (they throw), so the size is taken from the first frame. This fully + // decodes that frame, which is only paid on web. + final frame = await codec.getNextFrame(); + width = frame.image.width; + height = frame.image.height; + frame.image.dispose(); + } else { + width = descriptor.width; + height = descriptor.height; + } + return (descriptor, frameCount, width, height); + } on Object catch (error) { + descriptor?.dispose(); + _logResizeWarning(file, error); + return null; + } finally { + codec?.dispose(); + buffer?.dispose(); + } } -Future _decodeImage( - File file, { +/// Creates the buffer for [file]. +/// +/// The path is only used when the file is known to be backed by the real file +/// system: `ImmutableBuffer.fromFilePath` reads `file.path` directly from +/// disk, which would bypass a custom `Config.fileSystem` whose bytes might +/// not be readable at their path (encrypted or in-memory file systems). On +/// web there is no file path to read from either. +Future _bufferFor(File file) async { + if (!kIsWeb && file.fileSystem is LocalFileSystem) { + return ui.ImmutableBuffer.fromFilePath(file.path); + } + return ui.ImmutableBuffer.fromUint8List(await file.readAsBytes()); +} + +/// Decodes the image described by [descriptor] into a png-encoded +/// [Uint8List] that fits within [width] and [height]. +/// +/// Decoding with a target size straight from the descriptor reads the file +/// once; no separate resize provider is needed. +Future _decodeResized( + ui.ImageDescriptor descriptor, { int? width, int? height, - bool allowUpscaling = false, -}) { - final shouldResize = width != null || height != null; - final fileImage = FileImage(file); - final image = shouldResize - ? ResizeImage( - fileImage, - width: width, - height: height, - allowUpscaling: allowUpscaling, - ) - : fileImage as ImageProvider; - - final completer = Completer(); - final stream = image.resolve(ImageConfiguration.empty); - - late final ImageStreamListener listener; - listener = ImageStreamListener( - (info, _) { - if (completer.isCompleted) return; - - stream.removeListener(listener); - image.evict(); - completer.complete(info.image); - }, - onError: (Object error, StackTrace? stackTrace) { - if (completer.isCompleted) return; - - stream.removeListener(listener); - completer.completeError(error, stackTrace); - }, +}) async { + final codec = await descriptor.instantiateCodec( + targetWidth: width, + targetHeight: height, ); + final frame = await codec.getNextFrame(); + try { + final data = await frame.image.toByteData(format: ui.ImageByteFormat.png); + return data!.buffer.asUint8List(); + } finally { + frame.image.dispose(); + codec.dispose(); + } +} - stream.addListener(listener); - return completer.future; +void _logResizeWarning(File file, Object error) { + cacheLogger.log( + 'ImageCacheManager: could not resize "${file.path}", ' + 'returning the original file ($error)', + CacheManagerLogLevel.warning, + ); } diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 9726adbd..49ca35b2 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_cache_manager description: Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. -version: 3.4.8 +version: 3.5.0 homepage: https://github.com/Baseflow/flutter_cache_manager topics: - cache diff --git a/flutter_cache_manager/test/helpers/mock_file_service.dart b/flutter_cache_manager/test/helpers/mock_file_service.dart index 9c191dbf..39aec863 100644 --- a/flutter_cache_manager/test/helpers/mock_file_service.dart +++ b/flutter_cache_manager/test/helpers/mock_file_service.dart @@ -1,10 +1,11 @@ -import 'dart:io'; +import 'dart:convert'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/src/web/file_service.dart'; import 'package:mockito/mockito.dart'; import '../mock.mocks.dart'; +import '../test_images.dart'; class MockFileService extends MockFileServiceBase { MockFileService._(); @@ -26,7 +27,7 @@ class MockFileService extends MockFileServiceBase { class TestResponse extends FileServiceResponse { @override Stream> get content async* { - var bytes = await File('test/images/image-120.png').readAsBytes(); + var bytes = base64Decode(imagePng120); var length = bytes.length; var firstPart = (length / 2).floor(); yield bytes.sublist(0, firstPart); diff --git a/flutter_cache_manager/test/image_cache_manager_test.dart b/flutter_cache_manager/test/image_cache_manager_test.dart index ce8ec599..0e1593c0 100644 --- a/flutter_cache_manager/test/image_cache_manager_test.dart +++ b/flutter_cache_manager/test/image_cache_manager_test.dart @@ -1,4 +1,4 @@ -import 'dart:io'; +import 'dart:convert'; import 'dart:typed_data'; import 'dart:ui'; @@ -9,6 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'cache_manager_test.dart'; import 'helpers/config_extensions.dart'; import 'helpers/test_configuration.dart'; +import 'test_images.dart'; const fileName = 'test.jpg'; const fileUrl = 'baseflow.com/test'; @@ -24,7 +25,7 @@ void main() { group('Test image resizing', () { test('Test original image size', () async { - final bytes = await getExampleImage(); + final bytes = exampleImage; await verifySize(bytes, 120, 120); }); @@ -127,6 +128,143 @@ void main() { expect(progress, isNotEmpty); }); }); + + group('Test image detection', () { + test('Image without file extension should be resized', () async { + const urlWithoutExtension = 'baseflow.com/avatar/123456'; + var config = createTestConfig(); + await config.returnsFile('avatar', data: exampleImage); + config.returnsCacheObject(urlWithoutExtension, 'avatar', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager + .getImageFile(urlWithoutExtension, maxWidth: 100) + .last + as FileInfo; + + var image = await result.file.readAsBytes(); + await verifySize(image, 100, 100); + }); + + test('Image with a non-image extension should be resized', () async { + // The stored file's extension does not come from the url, but from the + // Content-Type header of the response. A generic type such as + // application/octet-stream stores the file as .bin, even when the + // payload is an image. + const urlWithBinaryExtension = 'baseflow.com/image.bin'; + var config = createTestConfig(); + await config.returnsFile('image.bin', data: exampleImage); + config.returnsCacheObject(urlWithBinaryExtension, 'image.bin', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager + .getImageFile(urlWithBinaryExtension, maxWidth: 100) + .last + as FileInfo; + + var image = await result.file.readAsBytes(); + await verifySize(image, 100, 100); + expect(result.file.path.endsWith('.png'), isTrue); + }); + + test('Static webp should be resized', () async { + const urlWithWebpExtension = 'baseflow.com/image.webp'; + var config = createTestConfig(); + await config.returnsFile('image.webp', data: exampleWebp); + config.returnsCacheObject(urlWithWebpExtension, 'image.webp', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager + .getImageFile(urlWithWebpExtension, maxWidth: 100) + .last + as FileInfo; + + var image = await result.file.readAsBytes(); + await verifySize(image, 100, 100); + }); + + test('Bmp should be resized', () async { + const urlWithBmpExtension = 'baseflow.com/image.bmp'; + var config = createTestConfig(); + await config.returnsFile('image.bmp', data: exampleBmp); + config.returnsCacheObject(urlWithBmpExtension, 'image.bmp', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager + .getImageFile(urlWithBmpExtension, maxWidth: 100) + .last + as FileInfo; + + var image = await result.file.readAsBytes(); + await verifySize(image, 100, 100); + }); + + test('Non image should not be resized', () async { + const urlWithImageExtension = 'baseflow.com/image.png'; + var payload = utf8.encode('{"message":"not an image"}'); + var config = createTestConfig(); + await config.returnsFile('image.png', data: payload); + config.returnsCacheObject(urlWithImageExtension, 'image.png', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager + .getImageFile(urlWithImageExtension, maxWidth: 100) + .last + as FileInfo; + + expect(await result.file.readAsBytes(), payload); + }); + + test('Animated gif should not be resized', () async { + const urlOfAnimatedGif = 'baseflow.com/animation.gif'; + var payload = animatedGif; + var config = createTestConfig(); + await config.returnsFile('animation.gif', data: payload); + config.returnsCacheObject(urlOfAnimatedGif, 'animation.gif', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager.getImageFile(urlOfAnimatedGif, maxWidth: 100).last + as FileInfo; + + expect(await result.file.readAsBytes(), payload); + }); + + test('Animated webp should not be resized', () async { + const urlOfAnimatedWebp = 'baseflow.com/animation.webp'; + var payload = animatedWebp; + var config = createTestConfig(); + await config.returnsFile('animation.webp', data: payload); + config.returnsCacheObject(urlOfAnimatedWebp, 'animation.webp', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager.getImageFile(urlOfAnimatedWebp, maxWidth: 100).last + as FileInfo; + + expect(await result.file.readAsBytes(), payload); + }); + + test('Animated png should not be resized', () async { + const urlOfAnimatedPng = 'baseflow.com/animation.png'; + var payload = animatedApng; + var config = createTestConfig(); + await config.returnsFile('animation.png', data: payload); + config.returnsCacheObject(urlOfAnimatedPng, 'animation.png', validTill); + + var cacheManager = TestCacheManager(config); + var result = + await cacheManager.getImageFile(urlOfAnimatedPng, maxWidth: 100).last + as FileInfo; + + expect(await result.file.readAsBytes(), payload); + }); + }); } Future setupCacheManager() async { @@ -136,7 +274,7 @@ Future setupCacheManager() async { Future setupConfig({String? cacheKey}) async { var validTill = DateTime.now().add(const Duration(days: 1)); var config = createTestConfig(); - await config.returnsFile(fileName, data: await getExampleImage()); + await config.returnsFile(fileName, data: exampleImage); config.returnsCacheObject(fileUrl, fileName, validTill, key: cacheKey); return config; } @@ -154,6 +292,9 @@ Future verifySize( expect(height, expectedHeight); } -Future getExampleImage() { - return File('test/images/image-120.png').readAsBytes(); -} +final Uint8List exampleImage = base64Decode(imagePng120); +final Uint8List exampleWebp = base64Decode(imageWebp120); +final Uint8List exampleBmp = base64Decode(imageBmp120); +final Uint8List animatedGif = base64Decode(animatedGif120); +final Uint8List animatedWebp = base64Decode(animatedWebp120); +final Uint8List animatedApng = base64Decode(animatedApng120); diff --git a/flutter_cache_manager/test/images/image-120.png b/flutter_cache_manager/test/images/image-120.png deleted file mode 100644 index a02e94a1..00000000 Binary files a/flutter_cache_manager/test/images/image-120.png and /dev/null differ diff --git a/flutter_cache_manager/test/test_images.dart b/flutter_cache_manager/test/test_images.dart new file mode 100644 index 00000000..9dd1cfa5 --- /dev/null +++ b/flutter_cache_manager/test/test_images.dart @@ -0,0 +1,138 @@ +/// Images used by the tests, embedded as base64 so they can be decoded +/// without a file system. +/// +/// `flutter test --platform chrome` cannot read files: `dart:io` is not +/// available there. Keeping the bytes in the test bundle lets the same tests +/// run on the VM and in the browser, so the resize behaviour on web (where +/// `ImageDescriptor.width` and `height` are not supported) is covered too. +/// +/// All of them are 120x120, the minimal size the resize tests need, and are +/// kept as small as possible to stay readable. They were made with Pillow: +/// +/// ```python +/// img = Image.new('RGB', (120, 120), (32, 96, 192)) +/// img.quantize(colors=8).save('image-120.png', optimize=True) +/// ``` +library; + +/// Static 120x120 png. +const imagePng120 = + 'iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4AgMAAABECt5BAAAACVBMVEXwyB4gYMDIKCiUsMyeAA' + 'ABLElEQVR42u2WMY6DMBBFvwlIKV1kqbfMMXwEit2jpcwNUnAEH4UDpKAHydtkE+aPjWIJ7VKY' + 'Ann8mD/jGRswkNeHE2aF1avgggsueH+41lNNh3BLejcdYL5S2HSvewQ//BoXxc3v4AQAOBC+Po' + 'O0g/ZemDYifqYwJH5ZjNuBvYVllfiZF3FIagPtIL0pT0szR9WunH5/UncotQv5tkO1tnNsTuyj' + '3mlVOjPAoP5efF7XxZ2i7v3UjKZ2szMWOU/1ZuJWU/NXLw9XXpp7w/4fY4+ahs3EZ03nzcSDpm' + 'OGuC66z/BWZQsCq4XPOR1TKxulN6fuJR45s6zdMnPiEgfOjMQ9WxLfl8ak+h14HRWS6l7ju9Rm' + 'HKhGXJb++aCP4UmGUUV9/GtNPo5D/7oDP+j1N9kWT81DAAAAAElFTkSuQmCC'; + +/// Static 120x120 webp. +const imageWebp120 = + 'UklGRkwCAABXRUJQVlA4IEACAACQEQCdASp4AHgAPrVUpk0nJKOiJhqqAOAWiU3cLiYSK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VQD/////////+RJJJJJJJJIAqqqqqqqqqqqkkkkkkkkkAP//' + '///////4SSSSSSSSSQCqqqqqqqqqqpJJJJJJJJIA//////////kkkkkkkkkkAKqqqqqqqqqqUS' + 'SSSSSSSQD/////////+QpJJJJJJJIAqqqqqqqqqqpUkkkkkkkkAP/////////5ISSSSSSSSQCq' + 'qqqqqqqqqkpJJJJJJJIA//////////kkkkkkkkkkAKqqqqqqqqqqSSSSSSSSSQD/////////+S' + 'SSSSSSSSQAqqqqqqqqqqpJJJJJJJJJAP/////////5JJJJJJJJJAA='; + +/// Animated (3 frames) 120x120 gif. +const animatedGif120 = + 'R0lGODlheAB4AIEAAP////8AAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQACgAAACwAAA' + 'AAeAB4AAAI/wABCBxIsKDBgwgLBljIsKHDhxAjSpxIsWKAhBgzZrTIsaPHjw01ihwpEKTJkygv' + 'klyZMKXLlxNZyjQIs6ZNlTNz3tyZMqdPnkBB+tQZtKjFoTONKo2JlOXSpw+bOoVKFadUkVWpXi' + 'WZFerWkV2ffsUaVulYjWXNnsWY1uhatm2Dvm0ZF+hchHXt3qWZd+devn1t/lUYWPDggYUNHwaQ' + 'uObiko1fPmYc2eXkypYfY+6pefPJy55Ngg79cTTpjqZPH+2smmPq1kwXw3bNenbsw7Yrvs7tcD' + 'dvhr5/Wx0sPGLw38d5J8+93Hbz2c9hR289XXX109dJZw+93XP3zd8xh6KvPD5y+cbnE6cvvD5w' + '+77v88avOz9u/bb30+Yvuz9s/67/ZRVgVQNqVVtxwB2I4HB/LdibgggW6BWExUkoFoXCWbiUhm' + 'rJ5mCCHn7I4F4iLsShWxgil6JyKzLXonMvQhejdDNSV6N1N2KXo3Y7ctejdz+CF6R4Q5JXpHlH' + 'opekekuy16R7T8IXpXxT0lelfVfil6V+W/LXpX9fAhimgGNWFRAAIfkEAQoAAgAsAAAAAHgAeA' + 'CB////AP8AAAAAAAAACP8AAwgcSLBgQQEIEypcyBCAw4cQI0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Nl/a0ZtOJY+besf+WgR/l67hT9e3ns2d6U4dM1JoigbeEVEjMCCfF56uEOzIAI' + 'wcgAjhyAAABBTk1G/AAAAAAAAAAAAHcAAHcAAGQAAABBTFBIFgAAAAEPMP8REUJMQ+hfWgKnLa' + 'L/E2A+XAhWUDggxgAAAPQIAJ0BKngAeAA+0WKmTwKIlYABoJY27dXpzawCJqvkzIfQGNaRvTBb' + 'SX3uFhmq+sJIY+oFjax57YzSxIwT2xmhOT2kLnIVkYJ7YzSxIwHAAP7tCH//zNH75PsN5Af+J/' + 'D4djBSt/0IMH/t/qif6mdXfa0f1M74VG3IL/NWrelE4S4m+dTGVYWq+dUrY9Mh5VyiMuw3TD4g' + 'rStK/suynznFY9+IIR1h27tiyviT1KWzOMs0khTL+rzSBUKzAgTvyksmlCQAAA=='; + +/// Animated (3 frames) 120x120 png. +const animatedApng120 = + 'iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4AQMAAAADqqSRAAAABlBMVEUAgP8KCgrdKYvuAAAACG' + 'FjVEwAAAADAAAAAM7tusAAAAAaZmNUTAAAAAAAAAB4AAAAeAAAAAAAAAAAAAEACgAAjNzB+AAA' + 'ACVJREFUeNpjYGBgYGBgkP8PBUwMqGCUP8of5Y/yR/mj/FE+9fkA17QJBpLlpncAAAAaZmNUTA' + 'AAAAEAAAB4AAAAeAAAAAAAAAAAAAEACgAAF68rLAAAAClmZEFUAAAAAnja7cchEgAgDMCwHnyc' + 'n3caP9m4AFxVfQCHX++99973P/4eB2zCVlVhAAAAGmZjVEwAAAADAAAAeAAAAHgAAAAAAAAAAA' + 'ABAAoAAPo5+MUAAAArZmRBVAAAAAR42mNggAD+////////j4GJARWM8kf5o/xR/ih/lD/Kpz4f' + 'AH2rBvcc4MJOAAAAAElFTkSuQmCC';