Skip to content

Instantly share code, notes, and snippets.

@DarthSim
Created November 10, 2020 12:43
Show Gist options
  • Save DarthSim/82546556027cb8b90f3387c1f84ff8a3 to your computer and use it in GitHub Desktop.
Save DarthSim/82546556027cb8b90f3387c1f84ff8a3 to your computer and use it in GitHub Desktop.
import (
"imgproxy"
)
func foo() {
imgproxy.SetEndpoint("https://my-imgproxy.com")
imgproxy.SetKeySalt("MYKEY", "MYSALT")
imgproxyURL := imgproxy.NewUrl(
"local:///my_pic.jpg",
imgproxy.ResizeOption{imgproxy.Fill, 640, 480},
imgproxy.GravityOption{imgproxy.GravityCenter},
imgproxy.SharpenOption{0.5},
)
anotherURL := imgproxyURL.WithOptions(
imgproxy.FormatOption{"webp"}
)
imgproxyURL.String() // => https://my-imgproxy.com/jlkghgkjhg/rs:fill:640:480/g:ce/sh:0.5/plain/local:///my_pic.jpg
anotherURL.String() // => https://my-imgproxy.com/jlkghgkjhg/rs:fill:640:480/g:ce/sh:0.5/plain/local:///my_pic.jpg@webp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment