Storehouse.Renderer.Vix (Storehouse v0.2.0)

Copy Markdown View Source

Renders variants in the app, with libvips through Vix (Storehouse.Renderer): the default renderer when Vix is loaded.

# mix.exs
{:vix, "~> 0.31"}

An image is shrunk as it is loaded, never decoded whole when it need not be: a 6000 × 4000 JPEG made 1280 wide is read at an eighth of its size. It is turned as its EXIF says, never enlarged, converted to sRGB (or its profile kept, with profile: :keep), and saved without its metadata unless the preset keeps it (metadata: :all). A crop to a point (focus: {x, y}) keeps that point as near the middle as the image allows.

Which formats it reads and writes is libvips's: the precompiled one Vix brings reads JPEG, PNG, WebP, TIFF, GIF and AVIF, and writes all but AVIF; build Vix against the system's libvips for HEIC, or for AVIF.

Options

  • :quality - for a preset that gives none. The default is 80.
  • :max_pixels - the largest original it renders, in pixels, read from its header before a pixel is decoded: a larger one gives {:error, :too_large}. The default is 200,000,000 (a 200 MP photograph). Storehouse.Check's :max_pixels refuses most at upload; this one also holds for an image whose size the upload's first bytes did not say (a TIFF whose directory comes last).