justgook/elm-image/2.0.0

NOTE: the latest version is 5.0.0

Image

type alias Image =
Image

Data Model representing Image data, that can be used to create image, or convert primitives to use image pixels as data

Decoding

Bytes
-> Maybe
{ width : Width
, height : Height
, data : Image
}

Convert blob of image (png or bmp) into Image

Encoding

encodeBmp : Image -> Bytes

The BMP file format, also known as bitmap image file or device independent bitmap (DIB) file format or simply a bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device (such as a graphics adapter), especially on Microsoft Windows and OS/2 operating systems.

Note: Using BMP 32bit is discouraged due to lack of proper support across browsers

encodePng : Image -> Bytes

Portable Network Graphics (PNG) is a raster-graphics file-format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF).

PNG supports palette-based images (with palettes of 24-bit RGB or 32-bit RGBA colors), grayscale images (with or without alpha channel for transparency), and full-color non-palette-based RGB images (with or without alpha channel).

Construct

fromList : Width -> List Int -> Image

Create Image of List Int where each Int is 0xRRGGBBAA

fromList2d : List (List Int) -> Image

Create Image of List (List Int) where each Int is 0xRRGGBBAA

fromArray : Width -> Array Int -> Image

Create Image of Array Int where each Int is 0xRRGGBBAA

fromArray2d : Array (Array Int) -> Image

Create Image of Array (Array Int) where each Int is 0xRRGGBBAA

fromBytes : Decoder Image -> Bytes -> Image

Create Image of Bytes where each pixel is unsignedInt32 - 0xRRGGBBAA

Destruct

toList : Image -> List Int

Take Image of and converts it to List Int where each Int is 0xRRGGBBAA

toList2d : Image -> List (List Int)

Take Image of and converts it to matrix List (List Int) where each Int is 0xRRGGBBAA

toArray : Image -> Array Int

Take Image of and converts it to Array Int where each Int is 0xRRGGBBAA

toArray2d : Image -> Array (Array Int)

Take Image of and converts it to matrix Array (Array Int) where each Int is 0xRRGGBBAA

Helper Types

type alias Width =
Int

Just syntax sugar for easier understanding

type alias Height =
Int

Just syntax sugar for easier understanding