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 BuildURL()
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:
Ops
- see OperationsQuality
- see General ParametersUpscale
- see General ParametersDefaultMethod
- 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",
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"
Then, generate your URL:
url, err := picfit.BuildURL("image.jpg", "90x90", options)
if err != nil {
return fmt.Errorf("couldn't build picfit URL: %w", err)
}
- Ping us on twitter @thoas, @oibafsellig
- Fork the project
- Fix bugs