diff --git a/README.md b/README.md deleted file mode 100644 index 6718ab3..0000000 --- a/README.md +++ /dev/null @@ -1,83 +0,0 @@ -A simple image uploader over SSH for static image hosting. - -Normalize, strip, and upload images via scp. - -Usage: `imup [ -h | --help ] [SRC ...]` - -SRC may be a path or url to an image file, or a special value. - -* '-' read from stdin. -* '+' read from the system clipboard. - -If no SRC is provided, read from the system clipboard. - -## Sample Usage - -- From clipboard - ```zsh - $ imup - https://i.allemangd.dev/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.webp () - ``` - -- From file or URL - ```zsh - $ imup image.png ./image.jpeg 'https://example.com/image.webp' - https://i.allemangd.dev/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.webp (image.png) - https://i.allemangd.dev/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.webp (./image.jpeg) - https://i.allemangd.dev/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.webp (https://example.com/image.webp) - ``` - -- From stdin - ```zsh - $ convert image.png -resize 50% - | imup - - https://i.allemangd.dev/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.webp () - ``` - -## Installation and setup. - -This assumes you already have some hosted static files and ssh configured with write permissions to that directory. Images are copied to the host via `scp`. Thus authentication is deferred to other systems like VPN and SSH, and hosting is deferred to static web servers like nginx. This tool is only a convenience to normalize/strip image data and upload the files. - -The client depends on `imagemagick`, `scp`, and `xclip`. The host only needs to serve the static files. - -```zsh -apt install imagemagick ssh xclip -``` - -Copy `imup` to your `~/.zfunc` or somewhere else on your zsh `fpath`. Add the configuration to your `~/.zshrc`: - -``` -autoload -Uz imup -export IMUP_SCP_DIR="..." # The target location. -export IMUP_URL="..." # The base url to access images. -``` - -For example, on my host `allemangd.dev` I have the following nginx static server: - -``` -# nginx config -server { - listen 80; - # (ssl settings omitted) - - server_name i.allemangd.dev; - - location / { - root /var/www/i.allemangd.dev/; - autoindex on; - } -} -``` - -I've granted write permissions to `/var/www/i.allemangd.dev` to my ssh user, and configured an ssh host for that user. - -``` -# ssh config -Host imup-host - HostName ... - User ... - IdentifyFile ... -``` - -Then I set `IMUP_SCP_DIR="imup-host:/var/www/i.allemangd.dev` and `IMUP_URL=https://i.allemangd.dev` in my `~/.zshrc`. - -The development environment in `mise.toml` uses the local directory `./images/` for both of these to avoid hosting/authentication requirements while testing. diff --git a/images/.gitkeep b/images/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/imup b/imup deleted file mode 100755 index 31f4a51..0000000 --- a/imup +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env zsh - -functipn imup() { - for arg in ${@}; do - case "${arg}" in - -h|--help) - cat << EOF -Normalize, strip, and upload images via scp. - -Usage: imup [ -h | --help ] [SRC ...] - -SRC may be a path or url to an image file, or a special value. - -'-' read from stdin. -'+' read from the system clipboard. - -If no SRC is provided, read from the system clipboard. -EOF - return - ;; - esac - done - - local root="$(mktemp -d)" - trap "rm -r '$root'" EXIT - - local -a files - - for src in ${@:-+}; do - local name="$(uuidgen).webp" - local file="$root/$name" - - case $src in - +) - xclip -o -selection clipboard -t image/png > "$file" || continue - convert "$file" -strip "WEBP:$file" || continue - echo "${IMUP_URL:?}/$name" | xclip -i -selection clipboard - src="" - ;; - -) - convert - -strip "WEBP:$file" || continue - src="" - ;; - *) - convert "$src" -strip "WEBP:$file" || continue - ;; - esac - - files+=("$file") - echo "${IMUP_URL:?}/$name ($src)" - done - - [[ ! -z $files ]] && scp "${files[@]}" "${IMUP_SCP_DIR:?}/" -} - -imup "$@" diff --git a/mise.toml b/mise.toml deleted file mode 100644 index 6ac6c20..0000000 --- a/mise.toml +++ /dev/null @@ -1,3 +0,0 @@ -[env] -IMUP_SCP_DIR = "{{ config_root }}/images" -IMUP_URL = "file://{{ config_root }}/images"