Table of Contents

Shortnote

The article describes the procedure to convert P.J. Onori's iconic icon package for use with OpenNotifier. The same procedure can be applied to any carefully chosen icon package that contains icons with a suitable contrast level (preferably black and white icon sets since they are easy to invert using ImageMagick). Based on this, we created the org.grimore.iconic.opennotifier in Cydia which uses the icons for OpenNotifier.

Using tools such as mogrify, convert (ImageMagick), we can batch-create icons for use with OpenNotifier. The bash script assumes that the images are close to black and white (contrast wise) and proceeds in several steps.

Depending on whether the image appears on a black bezel (the filename is then prefixed by OpenNotifier with Black_ON_) or on a white bezel (prefixed by OpenNotifier with Silver_ON_), the script performs the following operations two times:

  1. The images are scaled down to no more than 14x14 and stored to a temporary file.
  2. The temporary image is enhanced by using mogrify's -contrast switch a few times (in this case 5 times).
  3. The temporary image is sharpened to get a clear icon.
  4. Finally, the image is converted to 14x20 or 27x40 depending on whether it is a display image (the filename ending with @2x) or a status bar image.

Procedure

An overview of the procedure is given in the representation below as a flow of filters.

Initially, the size of the image is unknown ($x,y$) and the final result is a 14x20 image. The same procedure is applied again for images that should be 27x40.

Note that this procedure preserves the aspect ratio of the image and that it would have been insufficient to just use -resize 14x20\! using ImageMagick's convert utility because the results would have been distorted.

Code

vo.sh
#!/bin/bash
###########################################################################
##  Copyright (C) Wizardry and Steamworks 2012 - License: GNU GPLv3      ##
##  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  ##
##  rights of fair usage, the disclaimer and warranty conditions.        ##
###########################################################################
#
# The script converts the SVG icons in the current
# folder to PNG icons that are suitable to use as
# status-bar icons.
 
mkdir -p png tmp
 
for i in *; do
  TYPE=`file -b $i | awk '{ print $5 }'`
  if [[ $TYPE == "image" ]]; then
    # Silver
    # 14x20
    convert  -background transparent -alpha on -channel rgba -resize 14x14\> $i tmp/tmp.png
    mogrify -contrast -contrast -contrast -contrast -contrast tmp/tmp.png
    mogrify -sharpen 1x2 tmp/tmp.png
    convert  -gravity center -background transparent -extent 14x20 tmp/tmp.png png/"Silver_ON_${i/.svg/.png}"
    # 27x40 (@2x)
    convert  -background transparent -alpha on -channel rgba -resize 27x27\> $i tmp/tmp.png
    mogrify -contrast -contrast -contrast -contrast -contrast tmp/tmp.png
    mogrify -sharpen 1x2 tmp/tmp.png
    convert  -gravity center -background transparent -extent 27x40 tmp/tmp.png png/"Silver_ON_${i/.svg/@2x.png}"
 
    # Black
    # 14x20
    convert  -background transparent -alpha on -channel rgba -resize 14x14\> $i tmp/tmp.png
    mogrify -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast tmp/tmp.png
    mogrify -sharpen 1x2 tmp/tmp.png
    convert  -gravity center -background transparent -extent 14x20 -negate tmp/tmp.png png/"Black_ON_${i/svg/png}"
    # 27x40
    convert  -background transparent -alpha on -channel rgba -resize 27x27\> $i tmp/tmp.png
    mogrify -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast -contrast tmp/tmp.png
    mogrify -sharpen 1x2 tmp/tmp.png
    convert  -gravity center -background transparent -extent 27x40 -negate tmp/tmp.png png/"Black_ON_${i/.svg/@2x.png}"
  fi
done

ios/status_bar_icons.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.