Permalink
Browse files

Adding bash script for generating image tags or css with correct sizes

  • Loading branch information...
1 parent b103df4 commit 7cdb3742d5c6413cf4b6b45b923e6132c368d49f @lovett committed Apr 7, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 img
View
23 img
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+if [[ $(which identify | wc -l) -eq 0 ]]; then
+ echo "identify doesn't seem to be available. Is Image Magick installed?"
+ exit
+fi
+
+MARKUP_TYPE="$1"
+IMG_FILE="$2"
+
+if [[ ! -e $IMG_FILE ]]; then
+ echo "Usage: $(basename $0) <html|css> <image file>"
+ exit
+fi
+
+if [[ $MARKUP_TYPE == "html" ]]; then
+ identify -format "<img src=\"$2\" width=\"%w\" height=\"%h\" alt=\"\" title=\"\" />" "$2"
+fi
+
+if [[ $MARKUP_TYPE == "css" ]]; then
+ echo "background: transparent url($2) no-repeat top left;"
+ identify -format "width: %wpx;\nheight: %hpx;" $2
+fi

0 comments on commit 7cdb374

Please sign in to comment.