mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
build_emoji: Use clean emoji sheets without Apple fallback images.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
85c94599c5
commit
80b9cffb3d
@@ -6,6 +6,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
from collections.abc import Iterator, Sequence
|
from collections.abc import Iterator, Sequence
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@@ -312,16 +313,25 @@ def setup_emoji_farms(cache_path: str, emoji_data: list[dict[str, Any]]) -> None
|
|||||||
f"emoji-datasource-{emojiset}",
|
f"emoji-datasource-{emojiset}",
|
||||||
"img",
|
"img",
|
||||||
emojiset,
|
emojiset,
|
||||||
"sheets-256",
|
"sheets-clean",
|
||||||
"64.png",
|
"64.png",
|
||||||
)
|
)
|
||||||
sheet_dst = os.path.join(TARGET_EMOJI_SHEETS, f"{emojiset}.webp")
|
sheet_dst = os.path.join(TARGET_EMOJI_SHEETS, f"{emojiset}.webp")
|
||||||
# From libwebp: [Q is] between 0 and 100. For lossy, 0 gives
|
|
||||||
# the smallest size and 100 the largest. For lossless, this
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
# parameter is the amount of effort put into the
|
# First quantize the image to 256 colors (like sheets-256 in
|
||||||
# compression: 0 is the fastest but gives larger files
|
# emoji-datasource); libvips can only do this when saving to a PNG.
|
||||||
# compared to the slowest, but best, 100.
|
quantized = os.path.join(tmpdir, "quantized.png")
|
||||||
subprocess.check_call(["vips", "copy", sheet_src, f"{sheet_dst}[lossless=true,Q=100]"])
|
subprocess.check_call(
|
||||||
|
["vips", "copy", sheet_src, f"{quantized}[palette,dither=0,effort=10]"]
|
||||||
|
)
|
||||||
|
|
||||||
|
# From libwebp: [Q is] between 0 and 100. For lossy, 0 gives
|
||||||
|
# the smallest size and 100 the largest. For lossless, this
|
||||||
|
# parameter is the amount of effort put into the
|
||||||
|
# compression: 0 is the fastest but gives larger files
|
||||||
|
# compared to the slowest, but best, 100.
|
||||||
|
subprocess.check_call(["vips", "copy", quantized, f"{sheet_dst}[lossless,Q=100]"])
|
||||||
|
|
||||||
# Set up standard emoji sets.
|
# Set up standard emoji sets.
|
||||||
for emojiset in ["google", "twitter"]:
|
for emojiset in ["google", "twitter"]:
|
||||||
|
Reference in New Issue
Block a user