justgook / elm-image / Image.Advanced

Image Info

source : Image.Internal.ImageData.Image -> Source

Get image type


type Source
    = Png
    | Bmp
    | Gif
    | Code

Possible image decoded type

Manipulations

map : (Basics.Int -> Basics.Int) -> Image.Internal.ImageData.Image -> Image.Internal.ImageData.Image

Apply a function on every pixel in an image.

get : Basics.Int -> Basics.Int -> Basics.Int -> Basics.Int -> Image.Internal.ImageData.Image -> Image.Internal.ImageData.Image

Returns an Image representing the underlying pixel data for a specified portion of the Image.

region =
    Image.get sx sy sw sh image

put : Basics.Int -> Basics.Int -> Image.Internal.ImageData.Image -> Image.Internal.ImageData.Image -> Image.Internal.ImageData.Image

Paints data from the given Image onto the other Image.

newImage =
    Image.put dx dy imageFrom imageTo

eval : Image.Internal.ImageData.Image -> Image.Internal.ImageData.Image

When decoding images they are decoded in lazy way (real decoding is postponed until data is needed) this function evaluates postponed decode, useful if you need to encode multiple images from same source.

mirror : Basics.Bool -> Basics.Bool -> Image.Internal.ImageData.Image -> Image.Internal.ImageData.Image

Mirror image horizontally or/and vertically

newImage =
    Image.mirror x y image

Custom Encoding

toPng32 : Image.Internal.ImageData.Image -> Bytes

Encode image into True color with alpha PNG image

toBmp24 : Image.Internal.ImageData.Image -> Bytes

Encode image into BMP24

toBmp32 : Image.Internal.ImageData.Image -> Bytes

Encode image into BMP32

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

toGIF89a : Image.Internal.ImageData.Image -> Bytes

Encode image into GIF89a

Note:

  1. Gif supports only 256 colors in palette - if image have more that 256 colors, all colors that exceed 256 will become first color in palette
  2. Gif supports only fully transparent color, all colors that isn't fully transparent (alpha > 0) will be flatted to it color