README,docs: format and update URLs

Format docs with prettier. Update godoc.org URLs to pkg.go.dev.
This commit is contained in:
Will Norris 2025-04-30 23:32:32 -07:00
parent 7502adde1c
commit 8170536e41
5 changed files with 313 additions and 265 deletions

View file

@ -41,7 +41,7 @@ list of parameters, which can be supplied in any order. Duplicate parameters
overwrite previous values. overwrite previous values.
See the full list of available options at See the full list of available options at
<https://godoc.org/willnorris.com/go/imageproxy#ParseOptions>. <https://pkg.go.dev/willnorris.com/go/imageproxy#ParseOptions>.
### Remote URL ### Remote URL
@ -76,7 +76,7 @@ source image][small-things], which measures 1024 by 678 pixels.
| 200x,png | 200px wide, converted to PNG format | <a href="https://willnorris.com/api/imageproxy/200x,png/https://willnorris.com/images/imageproxy/small-things.jpg"><img src="https://willnorris.com/api/imageproxy/200x,png/https://willnorris.com/images/imageproxy/small-things.jpg" alt="200x,png"></a> | | 200x,png | 200px wide, converted to PNG format | <a href="https://willnorris.com/api/imageproxy/200x,png/https://willnorris.com/images/imageproxy/small-things.jpg"><img src="https://willnorris.com/api/imageproxy/200x,png/https://willnorris.com/images/imageproxy/small-things.jpg" alt="200x,png"></a> |
| cx175,cw400,ch300,100x | crop to 400x300px starting at (175,0), scale to 100px wide | <a href="https://willnorris.com/api/imageproxy/cx175,cw400,ch300,100x/https://willnorris.com/images/imageproxy/small-things.jpg"><img src="https://willnorris.com/api/imageproxy/cx175,cw400,ch300,100x/https://willnorris.com/images/imageproxy/small-things.jpg" alt="cx175,cw400,ch300,100x"></a> | | cx175,cw400,ch300,100x | crop to 400x300px starting at (175,0), scale to 100px wide | <a href="https://willnorris.com/api/imageproxy/cx175,cw400,ch300,100x/https://willnorris.com/images/imageproxy/small-things.jpg"><img src="https://willnorris.com/api/imageproxy/cx175,cw400,ch300,100x/https://willnorris.com/images/imageproxy/small-things.jpg" alt="cx175,cw400,ch300,100x"></a> |
The [smart crop feature](https://godoc.org/willnorris.com/go/imageproxy#hdr-Smart_Crop) The [smart crop feature](https://pkg.go.dev/willnorris.com/go/imageproxy#hdr-Smart_Crop-ParseOptions)
can best be seen by comparing crops of [this source image][judah-sheets], with can best be seen by comparing crops of [this source image][judah-sheets], with
and without smart crop enabled. and without smart crop enabled.
@ -182,7 +182,7 @@ first check an in-memory cache for an image, followed by a gcs bucket:
imageproxy -cache memory -cache gcs://my-bucket/ imageproxy -cache memory -cache gcs://my-bucket/
[tiered fashion]: https://godoc.org/github.com/die-net/lrucache/twotier [tiered fashion]: https://pkg.go.dev/github.com/die-net/lrucache/twotier
#### Cache Duration #### Cache Duration
@ -263,7 +263,7 @@ Reload the [codercat URL][], and you should see an error message. Now load a
that it loads properly. that it loads properly.
[signed codercat URL]: http://localhost:8080/500,sXyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY=/https://octodex.github.com/images/codercat.jpg [signed codercat URL]: http://localhost:8080/500,sXyMwWKIC5JPCtlYOQ2f4yMBTqpjtUsfI67Sp7huXIYY=/https://octodex.github.com/images/codercat.jpg
[signature option]: https://godoc.org/willnorris.com/go/imageproxy#hdr-Signature [signature option]: https://pkg.go.dev/willnorris.com/go/imageproxy#hdr-Signature-ParseOptions
Some simple code samples for generating signatures in various languages can be Some simple code samples for generating signatures in various languages can be
found in [docs/url-signing.md](/docs/url-signing.md). Multiple valid signature found in [docs/url-signing.md](/docs/url-signing.md). Multiple valid signature

View file

@ -6,12 +6,15 @@ This file contains all notable changes to
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased] ## [Unreleased]
[Unreleased]: https://github.com/willnorris/imageproxy/compare/v0.9.0...HEAD [Unreleased]: https://github.com/willnorris/imageproxy/compare/v0.9.0...HEAD
## [0.10.0] (2020-04-02) ## [0.10.0] (2020-04-02)
[0.10.0]: https://github.com/willnorris/imageproxy/compare/v0.9.0...v0.10.0 [0.10.0]: https://github.com/willnorris/imageproxy/compare/v0.9.0...v0.10.0
### Added ### Added
- add support for multiple signature keys to support key rotation - add support for multiple signature keys to support key rotation
([ef09c1b](https://github.com/willnorris/imageproxy/commit/ef09c1b), ([ef09c1b](https://github.com/willnorris/imageproxy/commit/ef09c1b),
[#209](https://github.com/willnorris/imageproxy/pull/209), [#209](https://github.com/willnorris/imageproxy/pull/209),
@ -23,6 +26,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[benhaan](https://github.com/benhaan)) [benhaan](https://github.com/benhaan))
### Fixed ### Fixed
- improved content type detection for some hosts, particularly S3 - improved content type detection for some hosts, particularly S3
([ea95ad9](https://github.com/willnorris/imageproxy/commit/ea95ad9), ([ea95ad9](https://github.com/willnorris/imageproxy/commit/ea95ad9),
[shahan312](https://github.com/shahan312)) [shahan312](https://github.com/shahan312))
@ -34,9 +38,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[fieldistor](https://github.com/fieldistor) for the suggested fix) [fieldistor](https://github.com/fieldistor) for the suggested fix)
## [0.9.0] (2019-06-10) ## [0.9.0] (2019-06-10)
[0.9.0]: https://github.com/willnorris/imageproxy/compare/v0.8.0...v0.9.0 [0.9.0]: https://github.com/willnorris/imageproxy/compare/v0.8.0...v0.9.0
### Added ### Added
- allow request signatures to cover options - allow request signatures to cover options
([#145](https://github.com/willnorris/imageproxy/issues/145)) ([#145](https://github.com/willnorris/imageproxy/issues/145))
- add simple imageproxy-sign tool for calculating signatures - add simple imageproxy-sign tool for calculating signatures
@ -50,6 +56,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
([d4ba520](https://github.com/willnorris/imageproxy/commit/d4ba520)) ([d4ba520](https://github.com/willnorris/imageproxy/commit/d4ba520))
### Changed ### Changed
- improvements to docker image: run as non-privileged user, use go1.12 - improvements to docker image: run as non-privileged user, use go1.12
compiler, and build imageproxy as a go module. compiler, and build imageproxy as a go module.
@ -64,6 +71,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
otherwise expired. otherwise expired.
### Fixed ### Fixed
- properly include Accept header on remote URL requests - properly include Accept header on remote URL requests
([#165](https://github.com/willnorris/imageproxy/issues/165), ([#165](https://github.com/willnorris/imageproxy/issues/165),
[6aca1e0](https://github.com/willnorris/imageproxy/commit/6aca1e0)) [6aca1e0](https://github.com/willnorris/imageproxy/commit/6aca1e0))
@ -71,13 +79,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
([cf54b2c](https://github.com/willnorris/imageproxy/commit/cf54b2c)) ([cf54b2c](https://github.com/willnorris/imageproxy/commit/cf54b2c))
### Removed ### Removed
- removed deprecated `whitelist` flag and `Proxy.Whitelist` struct field. Use - removed deprecated `whitelist` flag and `Proxy.Whitelist` struct field. Use
`allowHosts` and `Proxy.AllowHosts` instead. `allowHosts` and `Proxy.AllowHosts` instead.
## [0.8.0] (2019-03-21) ## [0.8.0] (2019-03-21)
[0.8.0]: https://github.com/willnorris/imageproxy/compare/v0.7.0...v0.8.0 [0.8.0]: https://github.com/willnorris/imageproxy/compare/v0.7.0...v0.8.0
### Added ### Added
- added support for restricting proxied URLs [based on Content-Type - added support for restricting proxied URLs [based on Content-Type
headers](https://github.com/willnorris/imageproxy#allowed-content-type-list) headers](https://github.com/willnorris/imageproxy#allowed-content-type-list)
([#141](https://github.com/willnorris/imageproxy/pull/141), ([#141](https://github.com/willnorris/imageproxy/pull/141),
@ -101,23 +112,28 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
as a module will be the only supported method of building imageproxy. as a module will be the only supported method of building imageproxy.
### Changed ### Changed
- when a remote URL is denied, return a generic error message that does not specify exactly why it failed - when a remote URL is denied, return a generic error message that does not specify exactly why it failed
([7e19b5c](https://github.com/willnorris/imageproxy/commit/7e19b5c)) ([7e19b5c](https://github.com/willnorris/imageproxy/commit/7e19b5c))
### Deprecated ### Deprecated
- `whitelist` flag and `Proxy.Whitelist` struct field renamed to `allowHosts` - `whitelist` flag and `Proxy.Whitelist` struct field renamed to `allowHosts`
and `Proxy.AllowHosts`. Old values are still supported, but will be removed and `Proxy.AllowHosts`. Old values are still supported, but will be removed
in a future release. in a future release.
### Fixed ### Fixed
- fixed tcp_mem resource leak on 304 responses - fixed tcp_mem resource leak on 304 responses
([#153](https://github.com/willnorris/imageproxy/pull/153), ([#153](https://github.com/willnorris/imageproxy/pull/153),
[Micr0mega](https://github.com/Micr0mega)) [Micr0mega](https://github.com/Micr0mega))
## [0.7.0] (2018-02-06) ## [0.7.0] (2018-02-06)
[0.7.0]: https://github.com/willnorris/imageproxy/compare/v0.6.0...v0.7.0 [0.7.0]: https://github.com/willnorris/imageproxy/compare/v0.6.0...v0.7.0
### Added ### Added
- added support for arbitrary [rectangular crops](https://godoc.org/willnorris.com/go/imageproxy#hdr-Rectangle_Crop) - added support for arbitrary [rectangular crops](https://godoc.org/willnorris.com/go/imageproxy#hdr-Rectangle_Crop)
([#90](https://github.com/willnorris/imageproxy/pull/90), ([#90](https://github.com/willnorris/imageproxy/pull/90),
[maciejtarnowski](https://github.com/maciejtarnowski)) [maciejtarnowski](https://github.com/maciejtarnowski))
@ -144,6 +160,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[afbd254](https://github.com/willnorris/imageproxy/commit/afbd254)) [afbd254](https://github.com/willnorris/imageproxy/commit/afbd254))
### Changed ### Changed
- rotate values are normalized, such that `r-90` is the same as `r270` - rotate values are normalized, such that `r-90` is the same as `r270`
([07c54b4](https://github.com/willnorris/imageproxy/commit/07c54b4)) ([07c54b4](https://github.com/willnorris/imageproxy/commit/07c54b4))
- now return `200 OK` response for requests to root `/` - now return `200 OK` response for requests to root `/`
@ -161,9 +178,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[matematik7](https://github.com/matematik7)) [matematik7](https://github.com/matematik7))
### Removed ### Removed
- removed deprecated `cacheDir` and `cacheSize` flags - removed deprecated `cacheDir` and `cacheSize` flags
### Fixed ### Fixed
- fixed interpretation of `Last-Modified` and `If-Modified-Since` headers - fixed interpretation of `Last-Modified` and `If-Modified-Since` headers
([#108](https://github.com/willnorris/imageproxy/pull/108), ([#108](https://github.com/willnorris/imageproxy/pull/108),
[jamesreggio](https://github.com/jamesreggio)) [jamesreggio](https://github.com/jamesreggio))
@ -171,9 +190,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
([#115](https://github.com/willnorris/imageproxy/issues/115)) ([#115](https://github.com/willnorris/imageproxy/issues/115))
## [0.6.0] (2017-08-29) ## [0.6.0] (2017-08-29)
[0.6.0]: https://github.com/willnorris/imageproxy/compare/v0.5.1...v0.6.0 [0.6.0]: https://github.com/willnorris/imageproxy/compare/v0.5.1...v0.6.0
### Added ### Added
- added health check endpoint - added health check endpoint
([#54](https://github.com/willnorris/imageproxy/pull/54), ([#54](https://github.com/willnorris/imageproxy/pull/54),
[immunda](https://github.com/immunda)) [immunda](https://github.com/immunda))
@ -191,6 +212,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[romdim](https://github.com/romdim)) [romdim](https://github.com/romdim))
### Fixed ### Fixed
- improved error messages for some authorization failures - improved error messages for some authorization failures
([27d5378](https://github.com/willnorris/imageproxy/commit/27d5378)) ([27d5378](https://github.com/willnorris/imageproxy/commit/27d5378))
- skip transformation when not needed - skip transformation when not needed
@ -200,16 +222,20 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[b61992e](https://github.com/willnorris/imageproxy/commit/b61992e)) [b61992e](https://github.com/willnorris/imageproxy/commit/b61992e))
## [0.5.1] (2015-12-07) ## [0.5.1] (2015-12-07)
[0.5.1]: https://github.com/willnorris/imageproxy/compare/v0.5.0...v0.5.1 [0.5.1]: https://github.com/willnorris/imageproxy/compare/v0.5.0...v0.5.1
### Fixed ### Fixed
- fixed bug in gif resizing - fixed bug in gif resizing
([gifresize@104a7cd](https://github.com/willnorris/gifresize/commit/104a7cd)) ([gifresize@104a7cd](https://github.com/willnorris/gifresize/commit/104a7cd))
## [0.5.0] (2015-12-07) ## [0.5.0] (2015-12-07)
[0.5.0]: https://github.com/willnorris/imageproxy/compare/v0.4.0...v0.5.0 [0.5.0]: https://github.com/willnorris/imageproxy/compare/v0.4.0...v0.5.0
## Added ## Added
- added Dockerfile - added Dockerfile
([#29](https://github.com/willnorris/imageproxy/pull/29), ([#29](https://github.com/willnorris/imageproxy/pull/29),
[sevki](https://github.com/sevki)) [sevki](https://github.com/sevki))
@ -227,30 +253,37 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[victortrac](https://github.com/victortrac)) [victortrac](https://github.com/victortrac))
## Changed ## Changed
- change default cache to none, and add `-cache` flag for specifying caches. - change default cache to none, and add `-cache` flag for specifying caches.
This deprecates the `-cacheDir` flag. This deprecates the `-cacheDir` flag.
- on-disk cache now stores files in a two-level trie. For example, for a file - on-disk cache now stores files in a two-level trie. For example, for a file
named "c0ffee", store file as "c0/ff/c0ffee". named "c0ffee", store file as "c0/ff/c0ffee".
## Fixed ## Fixed
- skip resizing if requested dimensions larger than original - skip resizing if requested dimensions larger than original
([#46](https://github.com/willnorris/imageproxy/pull/46), ([#46](https://github.com/willnorris/imageproxy/pull/46),
[orian](https://github.com/orian)) [orian](https://github.com/orian))
## [0.4.0] (2015-05-21) ## [0.4.0] (2015-05-21)
[0.4.0]: https://github.com/willnorris/imageproxy/compare/v0.3.0...v0.4.0 [0.4.0]: https://github.com/willnorris/imageproxy/compare/v0.3.0...v0.4.0
### Added ### Added
- added support for animated gifs - added support for animated gifs
([#23](https://github.com/willnorris/imageproxy/issues/23)) ([#23](https://github.com/willnorris/imageproxy/issues/23))
### Changed ### Changed
- non-200 responses from remote servers are proxied as-is - non-200 responses from remote servers are proxied as-is
## [0.3.0] (2015-12-07) ## [0.3.0] (2015-12-07)
[0.3.0]: https://github.com/willnorris/imageproxy/compare/v0.2.3...v0.3.0 [0.3.0]: https://github.com/willnorris/imageproxy/compare/v0.2.3...v0.3.0
### Added ### Added
- added support for signing requests using a sha-256 HMAC. - added support for signing requests using a sha-256 HMAC.
([a9efefc](https://github.com/willnorris/imageproxy/commit/a9efefc)) ([a9efefc](https://github.com/willnorris/imageproxy/commit/a9efefc))
- more complete logging of requests and whether response is from the cache - more complete logging of requests and whether response is from the cache
@ -260,38 +293,48 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
([#15](https://github.com/willnorris/imageproxy/issues/15)) ([#15](https://github.com/willnorris/imageproxy/issues/15))
### Fixed ### Fixed
- be more precise in copying over all headers from remote image response - be more precise in copying over all headers from remote image response
([1bf0515](https://github.com/willnorris/imageproxy/commit/1bf0515)) ([1bf0515](https://github.com/willnorris/imageproxy/commit/1bf0515))
## [0.2.3] (2015-02-20) ## [0.2.3] (2015-02-20)
[0.2.3]: https://github.com/willnorris/imageproxy/compare/v0.2.2...v0.2.3 [0.2.3]: https://github.com/willnorris/imageproxy/compare/v0.2.2...v0.2.3
### Added ### Added
- added quality option - added quality option
([#13](https://github.com/willnorris/imageproxy/pull/13) ([#13](https://github.com/willnorris/imageproxy/pull/13)
[cubabit](https://github.com/cubabit)) [cubabit](https://github.com/cubabit))
## [0.2.2] (2014-12-08) ## [0.2.2] (2014-12-08)
[0.2.2]: https://github.com/willnorris/imageproxy/compare/v0.2.1...v0.2.2 [0.2.2]: https://github.com/willnorris/imageproxy/compare/v0.2.1...v0.2.2
### Added ### Added
- added `cacheSize` flag to command line - added `cacheSize` flag to command line
### Changed ### Changed
- improved documentation and error messages - improved documentation and error messages
- negative width or height transformation values interpreted as 0 - negative width or height transformation values interpreted as 0
## [0.2.1] (2014-08-13) ## [0.2.1] (2014-08-13)
[0.2.1]: https://github.com/willnorris/imageproxy/compare/v0.2.0...v0.2.1 [0.2.1]: https://github.com/willnorris/imageproxy/compare/v0.2.0...v0.2.1
### Changed ### Changed
- restructured package so that the command line tools is now installed from - restructured package so that the command line tools is now installed from
`willnorris.com/go/imageproxy/cmd/imageproxy` `willnorris.com/go/imageproxy/cmd/imageproxy`
## [0.2.0] (2014-07-02) ## [0.2.0] (2014-07-02)
[0.2.0]: https://github.com/willnorris/imageproxy/compare/v0.1.0...v0.2.0 [0.2.0]: https://github.com/willnorris/imageproxy/compare/v0.1.0...v0.2.0
### Added ### Added
- transformed images are cached in addition to the original image - transformed images are cached in addition to the original image
([#1](https://github.com/willnorris/imageproxy/issues/1)) ([#1](https://github.com/willnorris/imageproxy/issues/1))
- support etag and last-modified headers on incoming requests - support etag and last-modified headers on incoming requests
@ -299,13 +342,16 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- support wildcards in list of allowed hosts - support wildcards in list of allowed hosts
### Changed ### Changed
- options can be specified in any order - options can be specified in any order
- images cannot be resized larger than their original dimensions - images cannot be resized larger than their original dimensions
## [0.1.0] (2013-12-26) ## [0.1.0] (2013-12-26)
[0.1.0]: https://github.com/willnorris/imageproxy/compare/5d75e8a...v0.1.0 [0.1.0]: https://github.com/willnorris/imageproxy/compare/5d75e8a...v0.1.0
Initial release. Supported transformation options include: Initial release. Supported transformation options include:
- width and height - width and height
- different crop modes - different crop modes
- rotation (in 90 degree increments) - rotation (in 90 degree increments)

View file

@ -27,7 +27,7 @@ eventually relent, and
[#49](https://github.com/willnorris/imageproxy/issues/49) tracked adding [#49](https://github.com/willnorris/imageproxy/issues/49) tracked adding
support for the most common backends. support for the most common backends.
Unfortunately my concerns proved true, and build times are *significantly* Unfortunately my concerns proved true, and build times are _significantly_
slower (TODO: add concrete numbers) now because of all the additional cloud slower (TODO: add concrete numbers) now because of all the additional cloud
SDKs that get compiled in. I don't personally care too much about binary size, SDKs that get compiled in. I don't personally care too much about binary size,
since I'm not running in a constrained environment, but these build times are since I'm not running in a constrained environment, but these build times are
@ -40,11 +40,12 @@ back out.
### Plugin support in Go ### Plugin support in Go
TODO: talk about options like TODO: talk about options like
- RPC (https://github.com/hashicorp/go-plugin)
- pkg/plugin (https://golang.org/pkg/plugin/) - RPC (<https://github.com/hashicorp/go-plugin>)
- embedded interpreter (https://github.com/robertkrimen/otto) - pkg/plugin (<https://golang.org/pkg/plugin/>)
- custom binaries (https://github.com/mholt/caddy, - embedded interpreter (<https://github.com/robertkrimen/otto>)
https://caddy.community/t/59) - custom binaries (<https://github.com/mholt/caddy>,
<https://caddy.community/t/59>)
Spoiler: I'm planning on following the Caddy approach and using custom Spoiler: I'm planning on following the Caddy approach and using custom
binaries. binaries.
@ -60,6 +61,7 @@ much about personally. Of course, users can also write their own plugins and
link them in without needing to contribute them to core if they don't want to. link them in without needing to contribute them to core if they don't want to.
I anticipate providing two or three build configurations in core: I anticipate providing two or three build configurations in core:
- **full** - include all the plugins that are part of core (except where they - **full** - include all the plugins that are part of core (except where they
may conflict) may conflict)
- **minimal** - some set of minimal features that only includes basic caching - **minimal** - some set of minimal features that only includes basic caching

View file

@ -19,14 +19,14 @@ Signatures can be calculated in two ways:
In both cases, the signature is calculated using HMAC-SHA256 and a secret key In both cases, the signature is calculated using HMAC-SHA256 and a secret key
which is provided to imageproxy on startup. The message to be signed is the which is provided to imageproxy on startup. The message to be signed is the
remote URL, with the transformation options optionally set as the URL fragment, remote URL, with the transformation options optionally set as the URL fragment,
[as documented below](#Signing-options). The signature is url-safe base64 [as documented below](#signing-options). The signature is url-safe base64
encoded, and [provided as an option][s-option] in the imageproxy request. encoded, and [provided as an option][s-option] in the imageproxy request.
imageproxy will accept signatures for URLs with or without options imageproxy will accept signatures for URLs with or without options
transparently. It's up to the publisher of the signed URLs to decide which transparently. It's up to the publisher of the signed URLs to decide which
method they use to generate the URL. method they use to generate the URL.
[s-option]: https://godoc.org/willnorris.com/go/imageproxy#hdr-Signature [s-option]: https://pkg.go.dev/willnorris.com/go/imageproxy#hdr-Signature-ParseOptions
## Signing options ## Signing options
@ -57,9 +57,8 @@ the signed value would be:
The `100` size option was put in its canonical form of `100x100`, and the The `100` size option was put in its canonical form of `100x100`, and the
options are sorted, moving `q75` before `r90`. options are sorted, moving `q75` before `r90`.
[ParseOptions]: https://godoc.org/willnorris.com/go/imageproxy#ParseOptions [ParseOptions]: https://pkg.go.dev/willnorris.com/go/imageproxy#ParseOptions
[size option]: https://godoc.org/willnorris.com/go/imageproxy#hdr-Size_and_Cropping [size option]: https://pkg.go.dev/willnorris.com/go/imageproxy#hdr-Size_and_Cropping-ParseOptions
## Signed options example ## Signed options example
@ -76,8 +75,6 @@ and our resulting signed key is `0sR2kjyfiF1RQRj4Jm2fFa3_6SDFqdAaDEmy1oD2U-4=`
The final url would be The final url would be
`http://localhost:8080/400x400,q40,s0sR2kjyfiF1RQRj4Jm2fFa3_6SDFqdAaDEmy1oD2U-4=/https://octodex.github.com/images/codercat.jpg` `http://localhost:8080/400x400,q40,s0sR2kjyfiF1RQRj4Jm2fFa3_6SDFqdAaDEmy1oD2U-4=/https://octodex.github.com/images/codercat.jpg`
## Language Examples ## Language Examples
Here are examples of calculating signatures in a variety of languages. These Here are examples of calculating signatures in a variety of languages. These
@ -90,6 +87,7 @@ See also the [imageproxy-sign tool](/cmd/imageproxy-sign).
### Go ### Go
main.go: main.go:
```go ```go
package main package main
@ -180,38 +178,40 @@ url = sys.argv[2]
print base64.urlsafe_b64encode(hmac.new(key, msg=url, digestmod=hashlib.sha256).digest()) print base64.urlsafe_b64encode(hmac.new(key, msg=url, digestmod=hashlib.sha256).digest())
``` ```
````shell ```shell
$ python sign.py "secretkey" "https://octodex.github.com/images/codercat.jpg" $ python sign.py "secretkey" "https://octodex.github.com/images/codercat.jpg"
cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM= cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM=
```` ```
### JavaScript ### JavaScript
```javascript ```javascript
const crypto = require('crypto'); const crypto = require("crypto");
const URLSafeBase64 = require('urlsafe-base64'); const URLSafeBase64 = require("urlsafe-base64");
let key = process.argv[2]; let key = process.argv[2];
let url = process.argv[3]; let url = process.argv[3];
console.log(URLSafeBase64.encode(crypto.createHmac('sha256', key).update(url).digest())); console.log(
URLSafeBase64.encode(crypto.createHmac("sha256", key).update(url).digest()),
);
``` ```
````shell ```shell
$ node sign.js "secretkey" "https://octodex.github.com/images/codercat.jpg" $ node sign.js "secretkey" "https://octodex.github.com/images/codercat.jpg"
cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM= cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM=
```` ```
### PHP ### PHP
````php ```php
<?php <?php
$key = $argv[1]; $key = $argv[1];
$url = $argv[2]; $url = $argv[2];
echo strtr(base64_encode(hash_hmac('sha256', $url, $key, 1)), '/+' , '_-'); echo strtr(base64_encode(hash_hmac('sha256', $url, $key, 1)), '/+' , '_-');
```` ```
````shell ```shell
$ php sign.php "secretkey" "https://octodex.github.com/images/codercat.jpg" $ php sign.php "secretkey" "https://octodex.github.com/images/codercat.jpg"
cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM= cw34eyalj8YvpLpETxSIxv2k8QkLel2UAR5Cku2FzGM=
```` ```