The URLs of variants imgproxy renders
(Storehouse.Renderer): signed, so only the presets' sizes are ever
rendered, and the same every time, for a CDN in front of it to keep.
The app renders nothing, and stores nothing.
config :storehouse, Storehouse.Variants,
renderer:
{Storehouse.Renderer.Imgproxy,
url: "https://images.example.com",
key: System.fetch_env!("IMGPROXY_KEY"),
salt: System.fetch_env!("IMGPROXY_SALT"),
source: "s3://my-bucket/"},
presets: [photo: [widths: [640, 1280, 1920], format: [:webp, :original]]]A preset is written as imgproxy's processing options:
- a width alone is
w:<width>; a box,rs:fit:<width>:<height>, orrs:fill:<width>:<height>withfit: :coverand its gravity (g:ce,g:smfor:attentionand:entropy,g:fp:<x>:<y>); q:<quality>, when the preset gives one;f:<format>for one format; none for:original, or for several, which imgproxy chooses itself byAccept(withIMGPROXY_AUTO_WEBPorIMGPROXY_AUTO_AVIFon);scp:0forprofile: :keep,sm:0formetadata: :all(imgproxy strips metadata by default), a background asbg:<hex>;- then the preset's
options: [imgproxy: "…"], as they are:"sh:0.3/fq:webp:86:jpeg:90".
imgproxy never enlarges an image unless it is told to.
Options
:url- imgproxy's address (or the CDN's in front of it). Required.:keyand:salt- imgproxy's, in hex (IMGPROXY_KEY,IMGPROXY_SALT). Without them, URLs are unsigned (/insecure/): for development only, as anyone could ask for any size.:source- where imgproxy reads the original: a prefix the key is put after ("s3://my-bucket/","local:///"), or a function of the file that gives its address. The default is the store's URL of the file (Storehouse.url/2).:extension-trueends the URL with the format's extension (…/<source>.webp) in place off:. The default isfalse.
Its own addresses
For URLs of another shape (a CDN's Worker that signs them itself),
signed_path/2 gives the path imgproxy is asked, and a renderer of the
app's own builds the rest.
Summary
Functions
The path of variant for imgproxy, not yet signed:
/<processing options>/<encoded source>.
path signed with the options' :key and :salt: "/<signature><path>",
as imgproxy checks it (HMAC-SHA256 of the salt and the path), or
"/insecure<path>" without them.
Functions
@spec path(Storehouse.Variant.t(), Storehouse.File.t(), keyword()) :: String.t()
The path of variant for imgproxy, not yet signed:
/<processing options>/<encoded source>.
path signed with the options' :key and :salt: "/<signature><path>",
as imgproxy checks it (HMAC-SHA256 of the salt and the path), or
"/insecure<path>" without them.