A Go client library for generating URLs with picfit
$ go get github.com/ulule/picfit-go
First, import the package:
import "github.com/ulule/picfit-go"
Now, you can access the package through picfit
namespace.
The GenerateThumbnailURL()
function returns a pre-formatted URL for picfit server.
This function takes three required parameters:
path
- your original image pathgeometry
- width and height formatted like this:widthxheight
(example: "20x30")options
- picfit options
Supported options are:
Op
- see Operations (defaults tothumbnail
)Crop
- either crop image or not (true
orfalse
, defaults tofalse
)Upscale
- see General Parameters (defaults to0
)DefaultMethod
- see Methods (defaults todisplay
)SecretKey
- your secret key (see Security)
Options is just an instance of Options
struct:
// Create your own instance, with your own parameters.
options := &picfit.Options{
Op: "thumbnail",
Crop: false,
Upscale: 0,
BaseURL: "https://img.yourpicfitserver.com",
DefaultMethod: "display",
SecretKey: "$ecretkeyplizkeepitseeeecret"
}
// Or, use the default ones (same as above) with NewOptions()
options := picfit.NewOptions()
// And, of course, you can override everything...
options.BaseURL = "https://img.superserver.com"
options.SecretKey = "qwerty1234ohitsbad"
options.Crop = true
Then, generate your URL:
url, err := picfit.GenerateThumbnailURL("image.jpg", "90x90", options)
if err != nil {
fmt.Println("Oops, sorry guys")
}
- Ping us on twitter @thoas, @oibafsellig
- Fork the project
- Fix bugs