View Source Thumbp (ThumbP v0.1.5)
A Lightweight & Fast WebP Thumbnail Image Generator
Summary
Types
@type body() :: binary()
@type height() :: pos_integer()
@type quality() :: float() | non_neg_integer() | nil
@type target_size() :: pos_integer() | nil
@type width() :: pos_integer()
Functions
Create a thumbnail image
Examples
iex> content = File.read!("./test/assets/images/sample.jpg")
iex> Thumbp.create(content, 320, 240)
{:ok, <<82, 73, 70, 70, 102, 12, 0, 0, 87, 69, 66, 80, ...>>}
Create a thumbnail image with options
Quality
The quality ranges from 0 to 100, defaulting to 75.
Target size
You can also specify a target size in bytes, although this will increase the processing time by approximately 20% to 80%.
Examples
iex> content = File.read!("./test/assets/images/sample.jpg")
iex> Thumbp.create(content, 320, 240, quality: 50)
iex> Thumbp.create(content, 320, 240, target_size: 12_000)