Created
January 4, 2023 23:34
-
-
Save sjehutch/6b05c13d8cc7f55e1e65889f47b91398 to your computer and use it in GitHub Desktop.
add_iconset.sh
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
#Check if the convert and iconutil tools are installed. These tools are part of the ImageMagick suite and are required to create the iconset and icns file. | |
#!/bin/bash | |
# Check if the required tools are installed | |
if ! [ -x "$(command -v convert)" ]; then | |
echo "Error: convert tool is not installed." >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v iconutil)" ]; then | |
echo "Error: iconutil tool is not installed." >&2 | |
exit 1 | |
fi | |
# Set the name of the iconset | |
iconset_name="MyIconset" | |
# Set the path to the source image | |
source_image_path="path/to/source/image.png" | |
# Set the path to the destination folder | |
destination_folder_path="path/to/destination/folder" | |
# Create the iconset folder | |
mkdir "$destination_folder_path/$iconset_name.iconset" | |
# Convert the source image to the required sizes and copy them to the iconset folder | |
convert "$source_image_path" -resize 16x16 "$destination_folder_path/$iconset_name.iconset/icon_16x16.png" | |
convert "$source_image_path" -resize 32x32 "$destination_folder_path/$iconset_name.iconset/[email protected]" | |
convert "$source_image_path" -resize 32x32 "$destination_folder_path/$iconset_name.iconset/icon_32x32.png" | |
convert "$source_image_path" -resize 64x64 "$destination_folder_path/$iconset_name.iconset/[email protected]" | |
convert "$source_image_path" -resize 128x128 "$destination_folder_path/$iconset_name.iconset/icon_128x128.png" | |
convert "$source_image_path" -resize 256x256 "$destination_folder_path/$iconset_name.iconset/[email protected]" | |
convert "$source_image_path" -resize 256x256 "$destination_folder_path/$iconset_name.iconset/icon_256x256.png" | |
convert "$source_image_path" -resize 512x512 "$destination_folder_path/$iconset_name.iconset/[email protected]" | |
convert "$source_image_path" -resize 512x512 "$destination_folder_path/$iconset_name.iconset/icon_512x512.png" | |
convert "$source_image_path" -resize 1024x1024 "$destination_folder_path/$iconset_name.iconset/[email protected]" | |
# Create the icns file from the iconset | |
iconutil -c icns "$destination_folder_path/$iconset_name.iconset" | |
# Remove the iconset folder | |
rm -R "$destination_folder_path/$iconset_name.iconset" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment