Skip to content

Commit

Permalink
Initial commit of the slackgmote
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Ives committed May 24, 2016
0 parents commit ca54663
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Slackgmote

Slackgmote is a small utility that depends on imagemagic and converts animated gifs to slack emoji.
It supports cropping them as well. Output will always meet slack standards and be named:
`original_name_crop_slack.gif`

It is currently poorly written, not efficient, and has no tests. Feel free to re-write this in some
better way (like as a gem or something) and open a merge request. Or not. Whatever.

## Usage

`slackgmote path/to/gif.gif [WidthxHeight+offset+offset]`
25 changes: 25 additions & 0 deletions bin/slackgmote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /bin/bash

function usage {
echo Usage: $BASH_SOURCE gif.gif [crop SizeXxSizeY+OffsetX+OffsetY, ex: 120x120+10+10]
exit 1
}

img=$(echo $1 | sed 's/\.gif//')
crop=$2

max_wh=128
max_size=64000

if [[ -z $1 ]]; then
usage
fi

if [[ $crop ]]; then
convert ${img}.gif -coalesce -repage 0x0 -crop ${crop} +repage ${img}_crop.gif || usage
img=${img}_crop
fi
while [[ ! -e ${img}_slack.gif ]] || [[ $(ls -l ${img}_slack.gif | grep -o ' \d\d\d\d\d ' || echo 9999999) -gt $max_size ]]; do
convert -resize ${max_wh}x${max_wh} ${img}.gif ${img}_slack.gif
((--max_wh))
done

0 comments on commit ca54663

Please sign in to comment.