Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bin/gifme
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# GIF ME
# as in: "GIF ME AN ANIMATED GIF, DAMMIT"
#
# Use imagemagick to make an animated gif of awesome. Upload to CloudApp.
# Use imagemagick to make an animated gif of awesome. Upload to photos.natwelch.com.
#
# Examples:
#
# gifme ~/Desktop/rtomayko.png ~/Desktop/pimpcane.jpg
# gifme ~/IncriminatingPhotosOfKyle/*.jpg

set -e

output="$HOME/Desktop/animated.gif"

# Set delay to be 20 unless we set $DELAY
delay=${DELAY-20}

convert -verbose -delay "$delay" -loop 0 -resize 500 -layers OptimizeTransparency \
"$@" "$output"
magick -delay "$delay" -loop 0 "$@" -resize 500 -layers OptimizeTransparency "$output"

# comment out if you don't need CloudApp.
cloudapp "$output"
photo "$output"
37 changes: 37 additions & 0 deletions bin/photo
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
#
# Upload images to photos.natwelch.com and print their URLs.
#
# Examples:
#
# photo ~/Desktop/cat.jpg
# photo ~/Desktop/*.png

set -euo pipefail

if [ $# -eq 0 ]; then
echo "usage: photo FILE..." >&2
exit 1
fi

args=()
for f in "$@"; do
f=${f//\\/\\\\}
args+=(-F "photo=@\"${f//\"/\\\"}\"")
done

body=$(curl -sS --fail-with-body "${args[@]}" https://photos.natwelch.com/api/upload) || {
jq -r '.message // empty' <<<"$body" >&2
exit 1
}
urls=$(jq -r '.files[].url' <<<"$body")

if [ -z "$urls" ]; then
echo "photo: nothing uploaded, only image files are accepted" >&2
exit 1
fi

printf '%s\n' "$urls"
if command -v pbcopy >/dev/null; then
printf '%s' "$urls" | pbcopy
fi
34 changes: 34 additions & 0 deletions bin/video
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# Upload videos to videos.natwelch.com and print their watch URLs. Each URL
# works once the background WebM conversion finishes.
#
# Examples:
#
# video ~/Desktop/demo.mov
# video ~/Movies/*.mp4

set -euo pipefail

if [ $# -eq 0 ]; then
echo "usage: video FILE..." >&2
exit 1
fi

args=()
for f in "$@"; do
f=${f//\\/\\\\}
args+=(-F "video=@\"${f//\"/\\\"}\"")
done

body=$(curl -sS --fail-with-body "${args[@]}" https://videos.natwelch.com/api/upload) || {
jq -r '.message // empty' <<<"$body" >&2
exit 1
}
year=$(date -u +%Y)
urls=$(jq -r --arg year "$year" '.jobs[] | "https://videos.natwelch.com/videos/\($year)/\(.id | sub("\\.[^.]+$"; "")).webm"' <<<"$body")

printf '%s\n' "$urls"
if command -v pbcopy >/dev/null; then
printf '%s' "$urls" | pbcopy
fi
Loading