Skip to content

Commit c4cceae

Browse files
committed
Use pngquant to further reduce filesize
1 parent 47f9307 commit c4cceae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

anim_encoder.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,16 @@ def generate_animation(anim_name):
227227
if os.system("pngcrush -q " + anim_name + "_packed_tmp.png " + anim_name + "_packed.png") == 0:
228228
os.system("rm " + anim_name + "_packed_tmp.png")
229229
else:
230-
print("pngcrush not found, output will not be larger")
230+
print("pngcrush not found, unable to reduce filesize")
231231
os.system("mv " + anim_name + "_packed_tmp.png " + anim_name + "_packed.png")
232232

233+
# Try to use pngquant since it can significantly reduce filesize for screencasts
234+
# that don't include photos or other sources of many different colors
235+
if os.system("pngquant -o " + anim_name + "_quant.png " + anim_name + "_packed.png") == 0:
236+
os.system("mv " + anim_name + "_quant.png " + anim_name + "_packed.png")
237+
else:
238+
print("pngquant not found, unable to reduce filesize")
239+
233240
# Generate JSON to represent the data
234241
delays = (array(times[1:] + [times[-1] + END_FRAME_PAUSE]) - array(times)).tolist()
235242

0 commit comments

Comments
 (0)