diff --git a/bin/gifme b/bin/gifme index 7fc00ed7..db43e450 100755 --- a/bin/gifme +++ b/bin/gifme @@ -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" diff --git a/bin/photo b/bin/photo new file mode 100755 index 00000000..466f853b --- /dev/null +++ b/bin/photo @@ -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 diff --git a/bin/video b/bin/video new file mode 100755 index 00000000..2250ddba --- /dev/null +++ b/bin/video @@ -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