diff --git a/README.md b/README.md index f0355a0..b226bb6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It's still in alpha because I've yet to implement ability to apply transformatio ## Quick Start -Installation options: +Quick start options: 1. Install globally: ```bash @@ -21,6 +21,22 @@ Installation options: 2. Via Makefile: Create a Makefile to run `enhanceddimg-go` programatically before your build command. +3. Import as a dependency (NOTE: Run BEFORE any http handlers!): + +```go +// Your web app's main module +import "github.com/seantiz/enhancedimg-go/enhancedimg" + +// IMPORTANT: Make a call to the EnhanceImages API before any http template handlers +// Change path argument passed to EnhanceImages as needed +func main() { + err := enhancedimg.EnhanceImages("./") + if err != nil { + log.Fatal(err) + } +} +``` + ## Features - Responsive web design supported but no data transforms handled yet. diff --git a/enhancedimg/api.go b/enhancedimg/api.go new file mode 100644 index 0000000..6f3bc58 --- /dev/null +++ b/enhancedimg/api.go @@ -0,0 +1,14 @@ +package enhancedimg + +import ( + "os" +) + +// EnhanceImages acts as the public API to use this package as a dependency +// path argument should be the path holding all html templates you want to be processed +func EnhanceImages(path string) error { + if err := os.MkdirAll("static/processed", 0755); err != nil { + return err + } + return FindAllImageElements(path) +}