[TxMt] Scriptable image processing system = sips
Martin Ström
mlists at burnfield.com
Fri May 12 18:18:48 UTC 2006
This is just a modified version of the Drop Command "Insert Image With
Dimensions" that alread exists
img="$TM_SELECTED_TEXT"
echo -n "<img src=\"$img\" "
sips -g pixelWidth -g pixelHeight "$img" \
|awk '/pixelWidth/ { printf("width=\"%d\" ", $2) }
/pixelHeight/ { printf("height=\"%d\" ", $2) }'
base=${img##*/}
alt=$(tr <<<${base%.*} '[_-]' ' '|perl -pe 's/(\w+)/\u$1/g')
echo -n "alt=\"\${1:$alt}\" />"
--
Input: Selected Text
Output: Insert as Snippet
ciao
Martin
On 5/12/06, Timothy Bates <timothy.c.bates at gmail.com> wrote:
> A while ago, I was try to make a command to add height and width information
> to turn a selected word " LBC0001A-1.tif " into code like:
>
> <img src="LBC0001A-1.tif" height="800"/>
>
>
>
> "sips", a built in command line tool seems to provide the required
> facilities, if anyone is interested in making such a command.
>
>
> sips -g all /Users/tim/Sites/favicon.png
> pixelWidth: 16
> pixelHeight: 16
> typeIdentifier: public.png
> format: png
> formatOptions: default
> dpiWidth: 95.987
> dpiHeight: 95.987
> samplesPerPixel: 4
> bitsPerSample: 8
> hasAlpha: yes
> space: RGB
>
> Can also resample and rotate images, etc.
>
> tim
>
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>
More information about the textmate
mailing list