Skip to content

Instantly share code, notes, and snippets.

@pgassmann
Created May 20, 2016 09:56
Show Gist options
  • Save pgassmann/04bc71df200b4ffca9842a690e1529ad to your computer and use it in GitHub Desktop.
Save pgassmann/04bc71df200b4ffca9842a690e1529ad to your computer and use it in GitHub Desktop.
Convert and resize black and white tif images to resized transparent, white pngs
#!/bin/bash
# Convert and resize black and white tif images to resized transparent, white pngs
# convert utility from imagemagick
# Author: Philipp Gassmann <phiphi@phiphi.ch>
# source: logo in multiple languages in folder translated as en.tif, de.tif etc.
# target: converted/logo_en.png ..., converted/logo_en@2x.png ...
for original in translated/*.tif ; do
convert $original -colorspace sRGB -depth 24 \
-transparent white -fill white -opaque black \
-resize 'x77' \
-unsharp 0x5 -colorspace RGB \
-set filename:fname 'logo_%t' png:'converted/%[filename:fname].png'
done
# HiDPI / Retina, double the size
for original in translated/*.tif ; do
convert $original -colorspace sRGB -depth 24 \
-transparent white -fill white -opaque black \
-resize 'x154' \
-unsharp 0x5 -colorspace RGB \
-set filename:fname 'logo_%t@2x' png:'converted/%[filename:fname].png'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment