mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-25 04:46:24 +02:00
allow percentage sizes
change height and width options to be floats, and interpret values between 0 and 1 to be percentages. For example, an options strings of "0.5x" specifies 50% width and proportional height.
This commit is contained in:
parent
036d0c51c4
commit
cd1112f7ac
4 changed files with 28 additions and 12 deletions
|
|
@ -91,11 +91,11 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if p.MaxWidth > 0 && req.Options.Width > p.MaxWidth {
|
||||
req.Options.Width = p.MaxWidth
|
||||
if p.MaxWidth > 0 && int(req.Options.Width) > p.MaxWidth {
|
||||
req.Options.Width = float64(p.MaxWidth)
|
||||
}
|
||||
if p.MaxHeight > 0 && req.Options.Height > p.MaxHeight {
|
||||
req.Options.Height = p.MaxHeight
|
||||
if p.MaxHeight > 0 && int(req.Options.Height) > p.MaxHeight {
|
||||
req.Options.Height = float64(p.MaxHeight)
|
||||
}
|
||||
|
||||
u := req.URL.String()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue