From 3f8e9a846b23e0fdbac20d6822fd4a114086faf9 Mon Sep 17 00:00:00 2001 From: Tad Date: Mon, 5 Aug 2019 20:34:08 -0400 Subject: [PATCH] Complete tree image optimization - recursively optimize images using optipng/jpegoptim benefits: + reduces image size + decreases load time + reduces memory usage --- PrebuiltApps | 2 +- Scripts/Common/Functions.sh | 6 ++++++ Scripts/LineageOS-11.0/Functions.sh | 1 + Scripts/LineageOS-14.1/Functions.sh | 1 + Scripts/LineageOS-15.1/Functions.sh | 1 + Scripts/LineageOS-16.0/Functions.sh | 1 + Scripts/init.sh | 1 + 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/PrebuiltApps b/PrebuiltApps index 849a37e0..e621fe0a 160000 --- a/PrebuiltApps +++ b/PrebuiltApps @@ -1 +1 @@ -Subproject commit 849a37e021f84355a75df6bf95c3587503bef065 +Subproject commit e621fe0adf3709dbcf9ac916593396d10cb60836 diff --git a/Scripts/Common/Functions.sh b/Scripts/Common/Functions.sh index 254aca50..554e3399 100644 --- a/Scripts/Common/Functions.sh +++ b/Scripts/Common/Functions.sh @@ -175,6 +175,12 @@ enableVerity() { } export -f enableVerity; +optimizeImagesRecursive() { + find "$1" -type f -name "*.jp*g" -print0 | xargs -0 -n1 -P 16 jpegoptim; + find "$1" -type f -name "*.png" -print0 | xargs -0 -n1 -P 16 optipng; +} +export -f optimizeImagesRecursive; + hardenLocationConf() { gpsConfig=$1; #Attempt to get the real device directory diff --git a/Scripts/LineageOS-11.0/Functions.sh b/Scripts/LineageOS-11.0/Functions.sh index 43293eec..ab0a8295 100644 --- a/Scripts/LineageOS-11.0/Functions.sh +++ b/Scripts/LineageOS-11.0/Functions.sh @@ -48,6 +48,7 @@ export -f buildDeviceDebug; buildAll() { if [ "$DOS_MALWARE_SCAN_ENABLED" = true ]; then scanWorkspaceForMalware; fi; + if [ "$DOS_OPTIMIZE_IMAGES" = true ]; then optimizeImagesRecursive "$DOS_BUILD_BASE"; fi; #Select devices are userdebug due to SELinux policy issues brunch lineage_nex-user; } diff --git a/Scripts/LineageOS-14.1/Functions.sh b/Scripts/LineageOS-14.1/Functions.sh index 96d2718b..678d6fdd 100644 --- a/Scripts/LineageOS-14.1/Functions.sh +++ b/Scripts/LineageOS-14.1/Functions.sh @@ -48,6 +48,7 @@ export -f buildDeviceDebug; buildAll() { if [ "$DOS_MALWARE_SCAN_ENABLED" = true ]; then scanWorkspaceForMalware; fi; + if [ "$DOS_OPTIMIZE_IMAGES" = true ]; then optimizeImagesRecursive "$DOS_BUILD_BASE"; fi; #Select devices are userdebug due to SELinux policy issues brunch lineage_clark-user; brunch lineage_thor-userdebug; diff --git a/Scripts/LineageOS-15.1/Functions.sh b/Scripts/LineageOS-15.1/Functions.sh index 91587e0e..90d1be62 100644 --- a/Scripts/LineageOS-15.1/Functions.sh +++ b/Scripts/LineageOS-15.1/Functions.sh @@ -48,6 +48,7 @@ export -f buildDeviceDebug; buildAll() { if [ "$DOS_MALWARE_SCAN_ENABLED" = true ]; then scanWorkspaceForMalware; fi; + if [ "$DOS_OPTIMIZE_IMAGES" = true ]; then optimizeImagesRecursive "$DOS_BUILD_BASE"; fi; brunch lineage_d852-user; brunch lineage_angler-user; brunch lineage_bullhead-user; diff --git a/Scripts/LineageOS-16.0/Functions.sh b/Scripts/LineageOS-16.0/Functions.sh index 5c6bbd85..6c5f9c0e 100644 --- a/Scripts/LineageOS-16.0/Functions.sh +++ b/Scripts/LineageOS-16.0/Functions.sh @@ -48,6 +48,7 @@ export -f buildDeviceDebug; buildAll() { if [ "$DOS_MALWARE_SCAN_ENABLED" = true ]; then scanWorkspaceForMalware; fi; + if [ "$DOS_OPTIMIZE_IMAGES" = true ]; then optimizeImagesRecursive "$DOS_BUILD_BASE"; fi; brunch lineage_mako-user; brunch lineage_bacon-user; brunch lineage_ether-user; diff --git a/Scripts/init.sh b/Scripts/init.sh index 2cb20f48..9c029929 100644 --- a/Scripts/init.sh +++ b/Scripts/init.sh @@ -44,6 +44,7 @@ export DOS_MALWARE_SCAN_ENABLED=true; #Set true to perform a fast scan on patchW export DOS_MALWARE_SCAN_SETTING="quick"; #buildAll() scan speed. Options: quick, extra, slow, full export DOS_MICROG_INCLUDED="NLP"; #Determines inclusion of microG. Options: NLP, FULL export DOS_NON_COMMERCIAL_USE_PATCHES=false; #Switch to false to prevent inclusion of non-commercial use patches XXX: Unused, see 1dc9247 +export DOS_OPTIMIZE_IMAGES=true; #Set true to apply lossless optimizations to image resources. Reduces image size and increases performance. export DOS_OVERCLOCKS_ENABLED=false; #Switch to false to disable overclocks #XXX: Most devices have their processors directly under their RAM, heatsinking is mostly into the ground plane, potentially inflicting damage to RAM and the processor itself export DOS_STRONG_ENCRYPTION_ENABLED=false; #Switch to true to enable AES-256bit encryption on 14.1+15.1 XXX: THIS WILL **DESTROY** EXISTING INSTALLS! export DOS_WIREGUARD_INCLUDED=false; #Switch to true to enable WireGuard kernel module inclusion