Archives for posts with tag: linux

Icons that are different sizes cause problems when you’re working on an app, but don’t want to spend multiple hours individually adjusting padding around each image. So I created a script that uses ImageMagick to size a batch of images to the same dimensions. To prevent clipping, I note the maximum width and height of each image in the batch before running the script, and supply this as my desired-size:


# Name some args

# Gotta have some parameters to continue
# First parameter should be image dimensions, i.e. contain 'x' in the middle.
if [ -z "$FINALSIZE" ] || [[ $FINALSIZE != *x* ]]; then
	if [[ $FINALSIZE != *x* ]]; then
		echo "desired-size not given!"
	echo "usage: desired-size file [file2 ...]"
	echo "         desired-size: Desired image dimensions, e.g. 164x120"
	exit 1

# Make sure we've got the magic butter
hash convert 2>/dev/null || { echo >&2 "MISSING convert COMMAND! INSTALL ImageMagick TO CONTINUE."; echo; exit 1; }

for INFILE in ${@:2}; do
	FILENAME=$(basename $INFILE)

	# Do the stuff
	# If your grays are fine, use this. Otherwise comment out, and use command below.
	convert $INFILE -background transparent -gravity center -extent $FINALSIZE $FILENAME

	# Sometimes this script messes up grays in your PNGs. If so, uncomment this:
	#convert $INFILE -define png:big-depth=16 -define png:color-type=6 -background transparent -gravity center -extent $FINALSIZE $FILENAME

Also on GitHub.

You could probably also modify this to find the correct dimensions based on the images you provide.

This script is meant for PNGs, but can easily be modified for any other image type, like a JPEG, by giving something other than transparent for the -background argument.

Known issues: I occasionally noticed that gray-colored icons got darker after running this script. After searching around, the commented-out convert line solved my problem. Utilizing it increases the file size slightly, but without a finer knowledge of PNGs, this was a quick and easy solution.

$ logout


After a fun day of attempts at crossgrading one of my machines to 64-bit Lubuntu, I needed to move my old local MySQL data to my new hard drive.

  1. Copy database folders stored in /var/lib/mysql/
  2. Change ownership of all databases to to mysql user: sudo chown -R mysql:mysql /var/lib/mysql/{my_database,my_other_database}


$ logout

I’ve accumulated a few laptops over the past five years. My first laptop “lasted” for four years of college (i.e. killed its first hard drive and was running Vista for most of its career), but I’ve since moved on to more powerful, non-Windows machines. Though four computers may seem a little unnecessary to my girlfriend, each still serves its own purpose in the various virtual ventures I partake in today.

Dell Inspiron · Windows 7 · Previously, my primary computer. Currently hooked to my MIDI-enabled piano for any time I want to work on some music. Occasionally turned on and remote desktop’d into when I really need IE or Photoshop.

System76 Gazelle Professional · Ubuntu 13.04 · Primary computer for everything; mostly-permanent denizen of my desk hooked to an external mouse, keyboard, hard drives, and second monitor.

Apple MacBook Pro · OS X 10.9 · Day job computer; occasional development and double pixel-density web testing at home.

Lenovo ThinkPad X201 · Lubuntu 12.10 · Primary “laptop,” i.e. portable computer; pretty much a dedicated development machine and replacement for my Samsung N130 netbook, whose two-year use inspired my full switch to Linux, and whose left-clicker recently went kaput.

$ logout