(cached? spec)
Given a spec, returns true
if the image/transformation combo is
cached on disk, false
otherwise.
Given a spec, returns `true` if the image/transformation combo is cached on disk, `false` otherwise.
(content-hash file-path
transform
{:keys [transformations cacheable-urls? resource-path]})
Compute a hash of the contents. If the configuration key :cacheable-urls?
is
false
, the hash will be faster, but less accurate, as it will only use the
file path and mtime, and not the actual file contents for the hash, along with
the transformation configuration. Always set :cacheable-urls?
to true
in
production environments.
Compute a hash of the contents. If the configuration key `:cacheable-urls?` is `false`, the hash will be faster, but less accurate, as it will only use the file path and mtime, and not the actual file contents for the hash, along with the transformation configuration. Always set `:cacheable-urls?` to `true` in production environments.
(image-spec url)
Parses the image URL to a map describing the desired file, output format and transformation.
Parses the image URL to a map describing the desired file, output format and transformation.
(image-url? url {:keys [prefix]})
Returns true if the URL is a request for a transformed image - e.g., starts with the configured prefix.
Returns true if the URL is a request for a transformed image - e.g., starts with the configured prefix.
(inflate-spec spec config)
Given a spec from image-spec
and a config map, validate and inflate
the spec so it includes all details necessary to perform the
transformation.
Given a spec from `image-spec` and a config map, validate and inflate the spec so it includes all details necessary to perform the transformation.
(realize-url config url)
Given an an URL that contains only a transformation and a file name, use the configuration to fully qualify it with a prefix and content hash.
Given an an URL that contains only a transformation and a file name, use the configuration to fully qualify it with a prefix and content hash.
(serve-image req config)
Prepare a Ring response for the image described by the request. Optionally caches the file on disk for better future performance.
Prepare a Ring response for the image described by the request. Optionally caches the file on disk for better future performance.
(transform-image transformation-config)
Transforms an image according to the transformation specs and returns
a BufferedImage
.
Transforms an image according to the transformation specs and returns a `BufferedImage`.
(url-to config transform file-path)
Given a config map, a keyword transform to apply, and the path to a file, return a URL that the middleware will recognize and process.
Given a config map, a keyword transform to apply, and the path to a file, return a URL that the middleware will recognize and process.
(validate-transformation-image-size image {:keys [transformations]})
(wrap-images handler & [config])
Ring middleware - intercept any request to the configured prefix, and serve transformed images from it.
Ring middleware - intercept any request to the configured prefix, and serve transformed images from it.
(write-image image
{:keys [ext quality progressive? width height transformations]
:as spec}
file-path)
Writes image
with the specified quality parameters to file-path
.
Creates necessary parent directories.
Writes `image` with the specified quality parameters to `file-path`. Creates necessary parent directories.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close