Modularized imagemagick code - closes #283