From 55a8005a7e429c1d7a8efa712a770350364f95b9 Mon Sep 17 00:00:00 2001 From: Mason Payne Date: Sat, 2 Mar 2024 17:10:03 -0700 Subject: [PATCH] add installation and build --- .gitignore | 1 + cmd/cli/cli.go | 2 +- go-executable-build.bash | 33 +++++++++++++++++++ installation-and-usage.md | 67 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 go-executable-build.bash create mode 100644 installation-and-usage.md diff --git a/.gitignore b/.gitignore index 7033af3..e2ebcf0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ output.mp4 resp.txt test.png resized.jpg +build/ \ No newline at end of file diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index f168892..abb55d5 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -31,7 +31,7 @@ func main() { app := &cli.App{ Name: "i2v", - Usage: "A command line tool to convert images to videos, based on Stability.ai's Rest API.", + Usage: "A command line tool to convert images to videos, based on Stability.ai's Rest API.\n\nSet the `STABILITY_API_KEY` environment variable to your API key.", Version: "v1.0.0", Description: "i2v (Image to Video) is a command line tool to convert images to videos, based on Stability.ai's Rest API.", Commands: commands, diff --git a/go-executable-build.bash b/go-executable-build.bash new file mode 100644 index 0000000..16e07ed --- /dev/null +++ b/go-executable-build.bash @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +package=$1 +package_name=$2 +if [[ -z "$package" ]]; then + echo "usage: $0 " + exit 1 +fi +package_split=(${package//\// }) +#package_name=${package_split[-1]} +if [[ -z "$package_name" ]]; then + package_name=${package_split[-1]} +fi + +platforms=("windows/amd64" "windows/arm64" "darwin/amd64" "darwin/arm64" "linux/amd64" "linux/arm64") + +for platform in "${platforms[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + output_name=$package_name'-'$GOOS'-'$GOARCH + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + output_name='build/'$output_name + + env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package + if [ $? -ne 0 ]; then + echo 'An error has occurred! Aborting the script execution...' + exit 1 + fi +done \ No newline at end of file diff --git a/installation-and-usage.md b/installation-and-usage.md new file mode 100644 index 0000000..cbcb1eb --- /dev/null +++ b/installation-and-usage.md @@ -0,0 +1,67 @@ +# i2v (Image to Video) + +## Get set up with stability.ai + +Set up an account with stability.ai add credits and set up an API key here: https://platform.stability.ai/account/keys + +Once you've created an API key you should set it as an environment variable on your system. Specific instructions for each platform can be found below. + +## How to install + +### Windows + +Download the file `i2v-windows-amd64.exe` or `i2v-windows-arm64.exe`. Place the file somewhere on your path. I usually change the name of the file to `i2v.exe`. + +I usually have a folder named 'bin' in my user's home folder. I then make sure that folder is on my path by adding it to the path system environment variable. Here is a link with instructions on how to do that: https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v=office.14) + +To set the API key in your environment you can follow the above linked instructions for updating your PATH variable but instead of changing your PATH, you can create a new variable. + +It should be called `STABILITY_API_KEY` and should have the value of the API key you created when you set up your stability.ai account. + +### Mac + +Download the file `i2v-darwin-amd64` or `i2v-darwin-arm64`. Place the file somewhere on your path. I usually change the name of the file to `i2v`. + +Set an environment variable named `STABILITY_API_KEY` with the value of the API key created when you set up your stability.ai account. + +### Linux + +Download the file `i2v-linux-amd64` or `i2v-linux-arm64`. Place the file somewhere on your path. I usually change the name of the file to `i2v`. + +Set an environment variable named `STABILITY_API_KEY` with the value of the API key created when you set up your stability.ai account. + +## Usage + +``` +% i2v -h # windows will be `i2v.exe -h` +NAME: + i2v - A command line tool to convert images to videos, based on Stability.ai's Rest API. + +USAGE: + i2v [global options] command [command options] [arguments...] + +VERSION: + v1.0.0 + +DESCRIPTION: + i2v (Image to Video) is a command line tool to convert images to videos, based on Stability.ai's Rest API. + +AUTHOR: + Mason Payne + +COMMANDS: + get-job-result, gjr Get the result of a job + resize, r Resize an image to a supported size for the API + help, h Shows a list of commands or help for one command + +GLOBAL OPTIONS: + --output value, -o value path to output file (should be a mp4) (default: "./output.mp4") + --format value, -f value The format to resize the image to wide, tall, or square (default: "wide") + --help, -h show help + --version, -v print the version + +COPYRIGHT: + 2023 Masonite Studios LLC +``` + +You can get more help for a specific command by adding the help option after the command e.g. `i2v resize -h` \ No newline at end of file