Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
3e7c0343
There was an error fetching the commit references. Please try again later.
Commit
3e7c0343
authored
1 year ago
by
drHyperion451
Committed by
JuanCStar
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Error handling for the icns generator script
parent
460b6be7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dist/icns_generator.sh
+72
-14
72 additions, 14 deletions
dist/icns_generator.sh
with
72 additions
and
14 deletions
dist/icns_generator.sh
+
72
−
14
View file @
3e7c0343
mkdir
suyu.iconset
convert
-background
none
-resize
16x16 suyu.svg suyu.iconset/icon_16x16.png
;
convert
-background
none
-resize
32x32 suyu.svg suyu.iconset/icon_16x16@2x.png
;
convert
-background
none
-resize
32x32 suyu.svg suyu.iconset/icon_32x32.png
;
convert
-background
none
-resize
64x64 suyu.svg suyu.iconset/icon_32x32@2x.png
;
convert
-background
none
-resize
128x128 suyu.svg suyu.iconset/icon_128x128.png
;
convert
-background
none
-resize
256x256 suyu.svg suyu.iconset/icon_256x256.png
;
convert
-background
none
-resize
256x256 suyu.svg suyu.iconset/icon_128x128@2x.png
;
convert
-background
none
-resize
512x512 suyu.svg suyu.iconset/icon_256x256@2x.png
;
convert
-background
none
-resize
512x512 suyu.svg suyu.iconset/icon_512x512.png
;
convert
-background
none
-resize
1024x1024 suyu.svg suyu.iconset/icon_512x512@2x.png
;
iconutil
-c
icns suyu.iconset
rm
-rf
suyu.iconset
#!/bin/bash
# icns_generator.sh GNU GPLv3 License
# Run this script when a new logo is made and the svg file inside.
# You should install Imagemagick to make the conversions: $brew install imagemagick
# Change working dir to where this script is located.
cd
"
${
0
%/*
}
"
if
[
-z
$1
]
;
then
echo
"icns_generator.sh GNU GPLv3 License"
echo
"Run this script when a new logo is made and the svg file inside."
echo
""
echo
"Syntax: ./icns_generator <input.svg>"
echo
""
echo
"Don't forget to install imagemagick: "
echo
"
$
brew install imagemagick"
exit
0
fi
# Error Handling Stuff:
## Check command availability
check_command
()
{
if
!
command
-v
"
$1
"
&> /dev/null
;
then
read
-s
-n
1
-p
"Error: '
$1
' command not found. Please install
$2
."
exit
1
fi
}
## Convert image with error handling
convert_image
()
{
convert
-background
none
-resize
"
$2
"
"
$1
"
"
$3
"
||
{
read
-s
-n
1
-p
"Error: Conversion failed for
$1
"
exit
1
}
}
# Check required commands
check_command
"convert"
"ImageMagick"
check_command
"iconutil"
"macOS"
# Create the iconset directory
mkdir
suyu.iconset
||
{
read
-s
-n
1
-p
"Error: Unable to create suyu.iconset directory."
exit
1
}
# Convert images
convert_image
"
$1
"
16x16 suyu.iconset/icon_16x16.png
convert_image
"
$1
"
32x32 suyu.iconset/icon_16x16@2x.png
convert_image
"
$1
"
32x32 suyu.iconset/icon_32x32.png
convert_image
"
$1
"
64x64 suyu.iconset/icon_32x32@2x.png
convert_image
"
$1
"
128x128 suyu.iconset/icon_128x128.png
convert_image
"
$1
"
256x256 suyu.iconset/icon_256x256.png
convert_image
"
$1
"
256x256 suyu.iconset/icon_128x128@2x.png
convert_image
"
$1
"
512x512 suyu.iconset/icon_256x256@2x.png
convert_image
"
$1
"
512x512 suyu.iconset/icon_512x512.png
convert_image
"
$1
"
1024x1024 suyu.iconset/icon_512x512@2x.png
# Create the ICNS file
iconutil
-c
icns suyu.iconset
||
{
read
-s
-n
1
-p
"Error: Failed to create ICNS file."
exit
1
}
# Remove the temporary iconset directory
rm
-rf
suyu.iconset
||
{
read
-s
-n
1
-p
"Error: Unable to remove suyu.iconset directory."
exit
1
}
echo
-s
-n
1
-p
"Icon generation completed successfully."
echo
""
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment