aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/postprocessor/embedthumbnail.py
diff options
context:
space:
mode:
authorlouie-github <30176969+louie-github@users.noreply.github.com>2021-05-22 02:09:48 +0800
committerGitHub <noreply@github.com>2021-05-21 23:39:48 +0530
commita927acb1ecf7cef80c24eca604b73d9b5e45b732 (patch)
tree20555dce879f952815532c2335578a6a3b7d0873 /yt_dlp/postprocessor/embedthumbnail.py
parent09f1580e2d29e256d753a8112f093d4e0a54478e (diff)
[ThumbnailsConvertor] Support conversion to `png` and make it the default (#333)
PNG, being a lossless format, should be a better default here compared to JPG since we won't be compressing to a lossy format and losing some of the original image data PNG is also supported for embedding in all the formats similar to JPEG Authored by: louie-github
Diffstat (limited to 'yt_dlp/postprocessor/embedthumbnail.py')
-rw-r--r--yt_dlp/postprocessor/embedthumbnail.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/yt_dlp/postprocessor/embedthumbnail.py b/yt_dlp/postprocessor/embedthumbnail.py
index 2d4f42a20..b0372225a 100644
--- a/yt_dlp/postprocessor/embedthumbnail.py
+++ b/yt_dlp/postprocessor/embedthumbnail.py
@@ -77,11 +77,14 @@ class EmbedThumbnailPP(FFmpegPostProcessor):
original_thumbnail = thumbnail_filename = info['thumbnails'][-1]['filepath']
- # Convert unsupported thumbnail formats to JPEG (see #25687, #25717)
+ # Convert unsupported thumbnail formats to PNG (see #25687, #25717)
+ # Original behavior was to convert to JPG, but since JPG is a lossy
+ # format, there will be some additional data loss.
+ # PNG, on the other hand, is lossless.
thumbnail_ext = os.path.splitext(thumbnail_filename)[1][1:]
if thumbnail_ext not in ('jpg', 'png'):
- thumbnail_filename = convertor.convert_thumbnail(thumbnail_filename, 'jpg')
- thumbnail_ext = 'jpg'
+ thumbnail_filename = convertor.convert_thumbnail(thumbnail_filename, 'png')
+ thumbnail_ext = 'png'
mtime = os.stat(encodeFilename(filename)).st_mtime