forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize png files by reducing amount of colors to 255 + use oxipng m…
…ax compressions Godot head have only 4 colors (counting transparent) but in non quantized form our files use dozens of colors. Usually 500 and up to 1000 in one of them. All additional colors are colors used to anti-alias the image. Lots of them are used in file only once or twice. They are mostly indistingusahble between each other so they are safe to remove When we reduce count of colors used by PNG file to 256, we can change it is mode to "Indexed". In this mode palette is created (up to 256 colors) and all the pixels are described not by using RGB(A) 3/4 bytes but by in index in palette 1 byte Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com>
- Loading branch information
Showing
36 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-8.02 KB
(44%)
misc/dist/ios_xcode/godot_ios/Images.xcassets/SplashImage.imageset/splash@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-8.02 KB
(44%)
misc/dist/ios_xcode/godot_ios/Images.xcassets/SplashImage.imageset/splash@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
# Requires ImageMagic 7+ | ||
# Requires oxipng 9.1.3+ | ||
|
||
import multiprocessing | ||
import subprocess | ||
import sys | ||
|
||
|
||
def quantize_image(filename, desired_colors): | ||
""" | ||
Godot head have only 4 colors (counting transparent) but in non quantized form our | ||
files use dozens of colors. Usually 500 and up to 1000 in one of them. All additional | ||
colors are colors used to anti-alias the image. Lots of them are used in file only once | ||
or twice. They are mostly indistingusahble between each other so they are safe to remove | ||
When we reduce count of colors used by PNG file to 256, we can change it is mode to | ||
"Indexed". In this mode palette is created (up to 256 colors) and all the pixels are | ||
described not by using RGB(A) 3/4 bytes but by in index in palette 1 byte | ||
""" | ||
|
||
# Retrieve amount of colors in the source image | ||
command = ["magick", filename, "-format", "%k", "info:-"] | ||
colors_count = int(subprocess.check_output(command)) | ||
|
||
# Reduce amount of colors in image 1 by 1 for each step | ||
# It is much slower then reducing to desired amount of colors in one call | ||
# and gives slightly worse results but produces output without any artifacts | ||
for i in range(colors_count, desired_colors, -1): | ||
command = ["magick", filename, "-dither", "None", "-colors", str(i), filename] | ||
subprocess.run(command) | ||
|
||
|
||
def optimize_image(filename): | ||
""" | ||
Uses `oxipng's` "max" compression to compress image even further | ||
""" | ||
command = ["oxipng", "-t1", "-omax", "-q", "--zopfli", "--zi", "255", "--strip", "all", filename] | ||
subprocess.run(command) | ||
|
||
|
||
def process_image(filename): | ||
print(f"quantize_image: {filename}") | ||
quantize_image(filename, 255) | ||
print(f"optimize_image: {filename}") | ||
optimize_image(filename) | ||
|
||
|
||
for i in range(1, len(sys.argv)): | ||
process = multiprocessing.Process(target=process_image, args=[sys.argv[i]]) | ||
process.start() |
Binary file modified
BIN
-8.01 KB
(44%)
platform/android/java/editor/src/horizonos/assets/vr_splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-330 Bytes
(83%)
platform/android/java/editor/src/main/res/mipmap-hdpi/ic_play_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-99 Bytes
(93%)
platform/android/java/editor/src/main/res/mipmap-mdpi/ic_play_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.42 KB
(44%)
platform/android/java/editor/src/main/res/mipmap-xhdpi/ic_play_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.24 KB
(41%)
platform/android/java/editor/src/main/res/mipmap-xxhdpi/ic_play_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.38 KB
(37%)
platform/android/java/editor/src/main/res/mipmap-xxxhdpi/ic_play_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-277 Bytes
(26%)
platform/android/java/lib/res/mipmap-hdpi/icon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.45 KB
(51%)
platform/android/java/lib/res/mipmap-hdpi/icon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-148 Bytes
(38%)
platform/android/java/lib/res/mipmap-mdpi/icon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-520 Bytes
(73%)
platform/android/java/lib/res/mipmap-mdpi/icon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-417 Bytes
(19%)
platform/android/java/lib/res/mipmap-xhdpi/icon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-2.36 KB
(46%)
platform/android/java/lib/res/mipmap-xhdpi/icon_foreground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-797 Bytes
(12%)
platform/android/java/lib/res/mipmap-xxhdpi/icon_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-4.27 KB
(41%)
platform/android/java/lib/res/mipmap-xxhdpi/icon_foreground.png
Oops, something went wrong.
Oops, something went wrong.
Binary file modified
BIN
-1.21 KB
(8.7%)
platform/android/java/lib/res/mipmap-xxxhdpi/icon_background.png
Oops, something went wrong.
Binary file modified
BIN
-6.99 KB
(37%)
platform/android/java/lib/res/mipmap-xxxhdpi/icon_foreground.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.