I wrote a script a while ago for when I want to post png images to Twitter. It uses ImageMagick. I'm going to put code tags around it in the hope that your blog will use those for formatting. 😀
#!/bin/bash
adds a strip of transparency to png images so twitter
won't convert them to jpg and make them look like crap
./png2twitter something.png
img="${1}";
outFile="$(mktemp)";
IFS=' ' read imgWidth imgHeight <<<$(identify -format "%w %h" "${img}");
((imgHeight++));
convert -size ${imgWidth}x${imgHeight} xc:transparent MIFF:- | composite "${img}" - "PNG:${outFile}";
mv "${outFile}" "${outFile}.png";
echo "new image is ${outFile}.png";
It's never mattered to me that the height of the image changes. Now I'm wondering if there's a simple way to make ImageMagick change opacity of a single pixel. So far I can only think of a rather convoluted method and a few minutes on Google found nothing useful.
I'm also now wondering why I've not made composite output to "PNG:${outFile}.png" instead of having that mv command.