-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Ives
committed
May 24, 2016
0 parents
commit ca54663
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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]` |
This file contains 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
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 |