Skip to content

thasophearak/moul

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moul

Opinionated Image Resizing Library

Installation

This package requires a static binary, https://github.com/moul-co/moul/releases >= v5.0.0-rc.5 to be in $PATH.

The package can be installed by adding moul to your list of dependencies in mix.exs:

def deps do
  [
    {:moul, "~> 0.4.0"}
  ]
end

There are two hashing options available:

By default, moul uses ThumbHash, but it can also be configured to use BlurHash.

config :moul,
  hash: "blurhash"

Example

test/images/DSCF0527.JPG
iex(1)> Moul.moulify("test/images/DSCF0527.JPG")
{:ok,
 %{
   hash: "yygKJQaEeJZ3B4rXhodHqHSHUGcH",
   height: "6240",
   width: "4160"
 }}

File created:

  • xl: test/images/DSCF0527/xl.jpeg
  • lg: test/images/DSCF0527/lg.jpeg
  • md: test/images/DSCF0527/md.jpeg
  • xs: test/images/DSCF0527/xs.jpeg
test/images/profile.png
iex(1)> Moul.avatarize("test/images/profile.png")
{:ok,
 %{
   hash: "GwgSFwKLZYZ/eHZHZ1aWZ4iHyAgpjaAC",
   height: "1190",
   width: "1190"
 }}

File created:

  • xl: test/images/profile/xl.jpeg
  • lg: test/images/profile/lg.jpeg
  • md: test/images/profile/md.jpeg
  • xs: test/images/profile/xs.jpeg

Preview: xl | blurhash | thumbhash

Documentation

Documentation can be found here: https://hexdocs.pm/moul