mirror of
https://github.com/1j01/textual-paint.git
synced 2024-10-26 17:36:53 +03:00
Save WebP files losslessly
This commit is contained in:
parent
4dbaf5145e
commit
1176fcee73
@ -31,7 +31,7 @@ This is a TUI (Text User Interface) image editor, inspired by MS Paint, built wi
|
||||
- [x] Bitmap (.bmp)
|
||||
- [x] GIF (.gif)
|
||||
- [x] TIFF (.tiff)
|
||||
- [x] WebP (.webp) — low quality <-- (TODO: lossless mode) -->
|
||||
- [x] WebP (.webp)
|
||||
- [x] JPEG (.jpg) — low quality <-- (TODO: set quality level? maybe enlarge image before saving?) -->
|
||||
- [x] Windows Icon (.ico) — opens largest size in the file
|
||||
- [x] Mac OS Icon (.icns) — opens largest size in the file
|
||||
|
@ -832,6 +832,8 @@ class AnsiArtDocument:
|
||||
print("File extension (normalized to uppercase):", file_type)
|
||||
exts = Image.registered_extensions()
|
||||
supported_extensions = [ext[1:].upper() for ext, f in exts.items() if f in Image.SAVE]
|
||||
print("Supported image formats by extension:", Image.EXTENSION)
|
||||
print("Supported image formats:", Image.SAVE)
|
||||
print("Supported image format file extensions:", supported_extensions)
|
||||
if file_type == "SVG":
|
||||
return self.get_svg().encode("utf-8")
|
||||
@ -846,6 +848,8 @@ class AnsiArtDocument:
|
||||
else:
|
||||
if file_type not in ["ANS", "NFO"]:
|
||||
print("Falling back to ANSI")
|
||||
# TODO: show message to user instead of silently using a different format
|
||||
# This is especially important now that we have read-only formats like .CUR
|
||||
# This maybe shouldn't use UTF-8...
|
||||
return self.get_ansi().encode("utf-8")
|
||||
|
||||
@ -863,7 +867,7 @@ class AnsiArtDocument:
|
||||
if file_type == "jpg":
|
||||
file_type = "jpeg"
|
||||
buffer = io.BytesIO()
|
||||
image.save(buffer, file_type)
|
||||
image.save(buffer, file_type, lossless=True)
|
||||
return buffer.getvalue()
|
||||
|
||||
def get_ansi(self) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user