Skip to content

Commit da2aa2d

Browse files
committed
Added script to "optimize emojis" and remove extra/unused ones, and updated translations to only use optimized emojis. This results in 936 emojis shipped with OpenShot, and less translations, faster loading, etc...
1 parent e143d24 commit da2aa2d

File tree

7 files changed

+2080
-12048
lines changed

7 files changed

+2080
-12048
lines changed

src/emojis/data/openmoji-optimized.json

+1
Large diffs are not rendered by default.

src/emojis/optimize-emojis.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
@file optimize-emojis.py
3+
@brief Remove unused emojis from the emojis/color/svg folder, and optimize data JSON file
4+
@author Jonathan Thomas <[email protected]>
5+
6+
@section LICENSE
7+
8+
Copyright (c) 2008-2018 OpenShot Studios, LLC
9+
(http://www.openshotstudios.com). This file is part of
10+
OpenShot Video Editor (http://www.openshot.org), an open-source project
11+
dedicated to delivering high quality video editing and animation solutions
12+
to the world.
13+
14+
OpenShot Video Editor is free software: you can redistribute it and/or modify
15+
it under the terms of the GNU General Public License as published by
16+
the Free Software Foundation, either version 3 of the License, or
17+
(at your option) any later version.
18+
19+
OpenShot Video Editor is distributed in the hope that it will be useful,
20+
but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
GNU General Public License for more details.
23+
24+
You should have received a copy of the GNU General Public License
25+
along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
26+
"""
27+
28+
from classes import info
29+
import os
30+
import json
31+
32+
REMOVE_CATEGORIES = ['flags', 'extras-unicode', 'extras-openmoji', 'component', 'symbols', 'people-body']
33+
34+
35+
# Get emoji metadata
36+
emoji_metadata_path = os.path.join(info.PATH, "emojis", "data", "openmoji.json")
37+
with open(emoji_metadata_path, 'r', encoding="utf-8") as f:
38+
emoji_metadata = json.load(f)
39+
40+
# Parse emoji metadata, and reshape data
41+
emoji_lookup = {}
42+
for emoji in emoji_metadata:
43+
if emoji.get('group') not in REMOVE_CATEGORIES:
44+
emoji_lookup[emoji.get("hexcode")] = emoji
45+
46+
# Loop through files and remove unused emojis
47+
emoji_removed_count = 0
48+
emoji_file_path = os.path.join(info.PATH, "emojis", "color", "svg")
49+
for filename in os.listdir(emoji_file_path):
50+
fileBaseName = os.path.splitext(filename)[0]
51+
emoji = emoji_lookup.get(fileBaseName, {})
52+
if not emoji:
53+
# Remove unused emoji
54+
emoji_path = os.path.join(emoji_file_path, filename)
55+
os.unlink(emoji_path)
56+
emoji_removed_count += 1
57+
print('Removed emoji: %s' % emoji_path)
58+
59+
# Save optimized data file
60+
emoji_metadata_optimized_path = os.path.join(info.PATH, "emojis", "data", "openmoji-optimized.json")
61+
with open(emoji_metadata_optimized_path, 'w', encoding='utf-8') as file:
62+
file.write(json.dumps(emoji_lookup))
63+
64+
print('Emojis Optimized (%s removed)!' % emoji_removed_count)

0 commit comments

Comments
 (0)