bash update

This commit is contained in:
Illya Marchenko 2019-11-17 22:55:25 +02:00
parent 033935bf67
commit fd853aebaa
3 changed files with 230 additions and 204 deletions

70
Makefile Normal file → Executable file

@ -1,4 +1,3 @@
#
# All-in-one website favicon generator
# Copyright (C) 2019 Illya Marchenko <stuzer05@gmail.com>
#
@ -15,8 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
CC = magick
FILE ?= source.png
CC = convert
SOURCE ?= source.png
# Files & forlders
DIST = dist
@ -102,51 +101,50 @@ override define file_source
@echo '<meta name="msapplication-config" content="'$(ICON_PATH)'ieconfig.xml">' >> $(DIST)source.html
endef
all: $(FILE)
-mkdir $(DIST) $(dist_public)
-mkdir $(DIST) $(dist_icons)
all: $(SOURCE)
-mkdir $(DIST) $(dist_public) $(dist_icons)
@echo "Generating.. Regular icons"
$(CC) $(FILE) -resize 16x16! $(dist_icons)favicon-16x16.png
$(CC) $(FILE) -resize 32x32! $(dist_icons)favicon-32x32.png
$(CC) $(FILE) -resize 48x48! $(dist_icons)favicon-48x48.png
$(CC) $(FILE) -resize 57x57! $(dist_icons)favicon-57x57.png
$(CC) $(FILE) -resize 76x76! $(dist_icons)favicon-76x76.png
$(CC) $(FILE) -resize 96x96! $(dist_icons)favicon-96x96.png
$(CC) $(FILE) -resize 128x128! $(dist_icons)favicon-128x128.png
$(CC) $(FILE) -resize 192x192! $(dist_icons)favicon-192x192.png
$(CC) $(FILE) -resize 192x192! $(dist_icons)favicon-196x196.png
$(CC) $(FILE) -resize 228x228! $(dist_icons)favicon-228x228.png
@$(CC) $(SOURCE) -resize 16x16! $(dist_icons)favicon-16x16.png
@$(CC) $(SOURCE) -resize 32x32! $(dist_icons)favicon-32x32.png
@$(CC) $(SOURCE) -resize 48x48! $(dist_icons)favicon-48x48.png
@$(CC) $(SOURCE) -resize 57x57! $(dist_icons)favicon-57x57.png
@$(CC) $(SOURCE) -resize 76x76! $(dist_icons)favicon-76x76.png
@$(CC) $(SOURCE) -resize 96x96! $(dist_icons)favicon-96x96.png
@$(CC) $(SOURCE) -resize 128x128! $(dist_icons)favicon-128x128.png
@$(CC) $(SOURCE) -resize 192x192! $(dist_icons)favicon-192x192.png
@$(CC) $(SOURCE) -resize 192x192! $(dist_icons)favicon-196x196.png
@$(CC) $(SOURCE) -resize 228x228! $(dist_icons)favicon-228x228.png
@echo "Packing.. triple-sized favicon.ico"
$(CC) $(dist_icons)favicon-16x16.png $(dist_icons)favicon-32x32.png $(dist_icons)favicon-48x48.png $(dist_public)favicon.ico
@$(CC) $(dist_icons)favicon-16x16.png $(dist_icons)favicon-32x32.png $(dist_icons)favicon-48x48.png $(dist_public)favicon.ico
@echo "Generating.. Android icons"
$(CC) $(FILE) -resize 196x196! $(dist_icons)favicon-196x196.png
$(CC) $(FILE) -resize 192x192! $(dist_icons)android-chrome-192x192.png
$(CC) $(FILE) -resize 196x196! $(dist_icons)android-chrome-512x512.png
@$(CC) $(SOURCE) -resize 196x196! $(dist_icons)favicon-196x196.png
@$(CC) $(SOURCE) -resize 192x192! $(dist_icons)android-chrome-192x192.png
@$(CC) $(SOURCE) -resize 196x196! $(dist_icons)android-chrome-512x512.png
@echo "Generating.. Apple icons"
$(CC) $(FILE) -resize 57x57! $(dist_icons)apple-touch-icon-57x57.png
$(CC) $(FILE) -resize 114x114! $(dist_icons)apple-touch-icon-114x114.png
$(CC) $(FILE) -resize 72x72! $(dist_icons)apple-touch-icon-72x72.png
$(CC) $(FILE) -resize 144x144! $(dist_icons)apple-touch-icon-144x144.png
$(CC) $(FILE) -resize 60x60! $(dist_icons)apple-touch-icon-60x60.png
$(CC) $(FILE) -resize 120x120! $(dist_icons)apple-touch-icon-120x120.png
$(CC) $(FILE) -resize 76x76! $(dist_icons)apple-touch-icon-76x76.png
$(CC) $(FILE) -resize 152x152! $(dist_icons)apple-touch-icon-152x152.png
$(CC) $(FILE) -resize 180x180! $(dist_icons)apple-touch-icon.png
$(CC) $(FILE) -resize 180x180! $(dist_public)apple-touch-icon.png
$(CC) $(FILE) -resize 180x180! -quality 80% $(dist_public)apple-touch-icon-precomposed.png
@$(CC) $(SOURCE) -resize 57x57! $(dist_icons)apple-touch-icon-57x57.png
@$(CC) $(SOURCE) -resize 114x114! $(dist_icons)apple-touch-icon-114x114.png
@$(CC) $(SOURCE) -resize 72x72! $(dist_icons)apple-touch-icon-72x72.png
@$(CC) $(SOURCE) -resize 144x144! $(dist_icons)apple-touch-icon-144x144.png
@$(CC) $(SOURCE) -resize 60x60! $(dist_icons)apple-touch-icon-60x60.png
@$(CC) $(SOURCE) -resize 120x120! $(dist_icons)apple-touch-icon-120x120.png
@$(CC) $(SOURCE) -resize 76x76! $(dist_icons)apple-touch-icon-76x76.png
@$(CC) $(SOURCE) -resize 152x152! $(dist_icons)apple-touch-icon-152x152.png
@$(CC) $(SOURCE) -resize 180x180! $(dist_icons)apple-touch-icon.png
@$(CC) $(SOURCE) -resize 180x180! $(dist_public)apple-touch-icon.png
@$(CC) $(SOURCE) -resize 180x180! -quality 80% $(dist_public)apple-touch-icon-precomposed.png
@echo "Generating.. IE 10 Metro tile icons"
$(CC) $(FILE) -resize 144x144! $(dist_icons)mstile-144x144.png
@$(CC) $(SOURCE) -resize 144x144! $(dist_icons)mstile-144x144.png
@echo "Generating.. IE 11 Metro tile for Windows 8.1 start screen"
$(CC) $(FILE) -resize 70x70! $(dist_icons)mstile-small.png
$(CC) $(FILE) -resize 150x150! $(dist_icons)mstile-medium.png
$(CC) $(FILE) -resize 310x150! $(dist_icons)mstile-wide.png
$(CC) $(FILE) -resize 310x310! $(dist_icons)mstile-large.png
@$(CC) $(SOURCE) -resize 70x70! $(dist_icons)mstile-small.png
@$(CC) $(SOURCE) -resize 150x150! $(dist_icons)mstile-medium.png
@$(CC) $(SOURCE) -resize 310x150! $(dist_icons)mstile-wide.png
@$(CC) $(SOURCE) -resize 310x310! $(dist_icons)mstile-large.png
@echo "Generating.. manifest.json"
$(file_manifest)

@ -6,7 +6,7 @@ This includes iOS Safari, Google Chrome, Mozilla Firefox, Windows 8 and 10, and
To get started with favicon generator you need to make sure [ImageMagick](https://imagemagick.org/index.php) and the latest [GNU make](https://www.gnu.org/software/make/) software are installed and present in your PATH environment variable.
# Configuration
By default, makefile uses `magick` filename for ImageMagick software, but you can change that by specifying a new name as a parameter for make
By default, makefile uses `convert` file of ImageMagick software, but you can change that by specifying a new name as a parameter for make
```
make CC=<executable name>
```
@ -24,53 +24,62 @@ or by changing the following line
FILE ?= <image filename>
```
# Using bash
You use bash script `generate.sh` to use the program anywhere on your system. First of, you have to areat a symbolic link to an executable using the following command
```bash
$ ln -s <path to program>/generate.sh ~/.local/bin/webicongen
# example: ln -s ~/Programs/Favicons_generation/generate.sh ~/.local/bin/webicongen
```
then you can use it in such a way
```bash
$ webicongen <image> <output dir>
```
The output directory will be created automatically.
# Usage
After everything is configured, simply place your image in the same directory as makefile, and then simply run `make`. It will generate the following directory structure
```
dist
│ source.html
└───public
│ apple-touch-icon-precomposed.png
│ apple-touch-icon.png
│ favicon.ico
│ manifest.json
└───icons
android-chrome-192x192.png
android-chrome-512x512.png
apple-touch-icon-114x114.png
apple-touch-icon-120x120.png
apple-touch-icon-144x144.png
apple-touch-icon-152x152.png
apple-touch-icon-57x57.png
apple-touch-icon-60x60.png
apple-touch-icon-72x72.png
apple-touch-icon-76x76.png
apple-touch-icon.png
favicon-128x128.png
favicon-16x16.png
favicon-192x192.png
favicon-196x196.png
favicon-228x228.png
favicon-32x32.png
favicon-48x48.png
favicon-57x57.png
favicon-76x76.png
favicon-96x96.png
ieconfig.xml
mstile-144x144.png
mstile-large.png
mstile-medium.png
mstile-small.png
mstile-wide.png
dist/
├── public
│   ├── apple-touch-icon.png
│   ├── apple-touch-icon-precomposed.png
│   ├── favicon.ico
│   ├── icons
│   │   ├── android-chrome-192x192.png
│   │   ├── android-chrome-512x512.png
│   │   ├── apple-touch-icon-114x114.png
│   │   ├── apple-touch-icon-120x120.png
│   │   ├── apple-touch-icon-144x144.png
│   │   ├── apple-touch-icon-152x152.png
│   │   ├── apple-touch-icon-57x57.png
│   │   ├── apple-touch-icon-60x60.png
│   │   ├── apple-touch-icon-72x72.png
│   │   ├── apple-touch-icon-76x76.png
│   │   ├── apple-touch-icon.png
│   │   ├── favicon-128x128.png
│   │   ├── favicon-16x16.png
│   │   ├── favicon-192x192.png
│   │   ├── favicon-196x196.png
│   │   ├── favicon-228x228.png
│   │   ├── favicon-32x32.png
│   │   ├── favicon-48x48.png
│   │   ├── favicon-57x57.png
│   │   ├── favicon-76x76.png
│   │   ├── favicon-96x96.png
│   │   ├── ieconfig.xml
│   │   ├── mstile-144x144.png
│   │   ├── mstile-large.png
│   │   ├── mstile-medium.png
│   │   ├── mstile-small.png
│   │   └── mstile-wide.png
│   └── manifest.json
└── source.html
```
`source.html` contains HTML code that needs to be pasted in your document's head.
`public` folder must be the same as your project's public folder, you can simply copy-paste it into your project (make sure you don't have one of these generated files already in your project, such as `manifest.json`).
# Acknowledgements
I would love to hear any ideas or issues regarding this makefile. Make sure to create an issue or a pull request.
You can also send me an email at stuzer05@gmail.com
You can also send me an email to stuzer05 at gmail.com

19
generate.sh Executable file

@ -0,0 +1,19 @@
#!/bin/bash
SCRIPT_FOLLOW=`realpath $0`
SCRIPT=`realpath -s $0`
SCRIPTPATH=`dirname $SCRIPT_FOLLOW`
CALLPATH=`pwd`
me=`basename "$0"`
DIST="dist"
if [ $# -eq 2 ]; then
DIST=$2
fi
if [ $# -gt 0 ]; then
make -C $SCRIPTPATH SOURCE="$(pwd)/$1" DIST="$CALLPATH/$DIST"
else
echo -e "Error: missing arguments\n"
echo -e "USAGE:"
echo -e "\t$me <image> <output dir>"
fi