Last active
December 15, 2015 08:19
-
-
Save gordonmeyer/5230354 to your computer and use it in GitHub Desktop.
This OS X bash script takes an image file as a parameter. The width and height of the image are identified, and a fully-qualified img tag is output. Note that the location of the image on the remote server is hardcoded and will need to be changed for your site. Read more about this script at:
http://www.gordonmeyer.com/2013/03/a-script-to-automa…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#gordonmeyer.com March 23, 2013 | |
#usage: imgref filename | |
#output: <img> tag | |
#requires: OS X | |
#credits: http://superuser.com/questions/273059/get-pixel-dimensions-of-a-png-on-my-mac | |
filename=$1 | |
if [ ! -f "$filename" ] ; then | |
echo "$filename not found!"; | |
exit 1 | |
fi | |
bname=$( basename "$filename") | |
prfx="<img src=\"http://www.chicagomagicstudio.com/map/gfx/" | |
h=$( sips -g pixelHeight "$filename" | tail -n1 | cut -d" " -f4 ) | |
w=$( sips -g pixelWidth "$filename" | tail -n1 | cut -d" " -f4 ) | |
theref=$( echo $prfx$bname\" width=\"$w\" height=\"$h\"\>\</br\>TITLE) | |
echo $theref |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.gordonmeyer.com/2013/03/a-script-to-automatically-create-a-complete-img-tag.html