Created
September 28, 2022 04:34
-
-
Save dardo82/58e1b2bfa810d8cd9660c25c5429108f to your computer and use it in GitHub Desktop.
Copy logos from dirs
This file contains hidden or 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
#!/bin/zsh | |
# Extract logos from folder icons | |
DL="Downloads"; G="Generic" | |
U="Utilities"; c="compare" | |
SB="Sidebar"; f="format" | |
I="Icon"; F="Folder" | |
mkdir -v Core | |
chdir ${_} | |
pwd; echo | |
FILES=($(echo /Sys*/Lib*/\ | |
Core*/**/*$F*.icns)) | |
for ICNS in $FILES; do | |
FILE=${ICNS##*/} | |
sips -s $f png $ICNS \ | |
--out ${FILE%.*}.png; done | |
mkdir -v Badge; mv -v *$_* $_ | |
mkdir -v $SB; mv -v *$_* $_ | |
mkdir -v $F; mv -v *$_* $_ | |
chdir $F; pwd | |
mv -v $U$F{,$I}.png | |
mv -v $DL$F{,$I}.png | |
mv -v Group$F{,$I}.png | |
ls -1 ./; echo; cd .. | |
mkdir -v Logos; cd $_ | |
GFI="./../$F/$G$F$I.png" | |
SIZE=$(file $GFI \ | |
| cut -d' ' -f5) | |
S=$[$SIZE/2] | |
P=$[$S/(2**1)] | |
Q=$[$P/(2**3)] | |
R=$[$P/(2**5)] | |
GM=${S}x${S}+$P+$[$P+($Q+$R)] | |
LLC=" -lowlight-color transparent" | |
HLC=" -highlight-color black" | |
SRC=" -compose src" | |
CROP="-crop $GM" | |
for PNG in ../$F/*.png; do | |
LOGO=${PNG/$F$I/Logo} | |
${=c} $GFI $PNG \ | |
${=HLC} ${=LLC} \ | |
${=SRC} ${=CROP} \ | |
${LOGO##*/}; file $_ | |
done; qlmanage -p *.png | |
rm -v $G* | |
rm -v Home* | |
rm -v Open* | |
rm -v Smart* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment