ulule / picfit-go

A Go client library for generating URLs with picfit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

picfit-go

Build Status

A Go client library for generating URLs with picfit

Installation

$ go get github.com/ulule/picfit-go

Usage

First, import the package:

import "github.com/ulule/picfit-go"

Now, you can access the package through picfit namespace.

API

BuildURL()

The BuildURL() function returns a pre-formatted URL for picfit server.

This function takes three required parameters:

  • path - your original image path
  • geometry - width and height formatted like this: widthxheight (example: "20x30")
  • options - picfit options

Supported options are:

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)
}

Contributing

About

A Go client library for generating URLs with picfit

License:MIT License


Languages

Language:Go 99.2%Language:Makefile 0.8%