Liking cljdoc? Tell your friends :D
ClojureScript only.

dgknght.app-lib.images

Preparing images in the browser for upload, e.g. shrinking a photo taken on a phone before sending it to the server.

Preparing images in the browser for upload, e.g. shrinking a photo
taken on a phone before sending it to the server.
raw docstring

resizecljs

(resize file)
(resize file
        {:keys [max-dimension quality type on-success on-error]
         :or {max-dimension 1024 quality 0.85 type "image/jpeg"}})

Draws the image file (a File or Blob) onto a canvas no larger than the maximum dimension, preserving the aspect ratio, and returns a js/Promise of the result as a Blob. Smaller images are not enlarged.

The image is decoded with createImageBitmap, which applies the photo's EXIF orientation by default, so sideways phone photos come out upright.

Options: :max-dimension - the largest the width or height may be, in pixels (default 1024) :quality - the encoding quality, between 0 and 1, for lossy types (default 0.85) :type - the MIME type of the resulting blob (default "image/jpeg") :on-success - called with the blob :on-error - called with the error if the image can't be read or encoded. When given, the promise resolves to its return value; otherwise the promise rejects.

Draws the image file (a File or Blob) onto a canvas no larger than
the maximum dimension, preserving the aspect ratio, and returns a
js/Promise of the result as a Blob. Smaller images are not enlarged.

The image is decoded with createImageBitmap, which applies the photo's
EXIF orientation by default, so sideways phone photos come out upright.

Options:
  :max-dimension - the largest the width or height may be, in pixels
                   (default 1024)
  :quality       - the encoding quality, between 0 and 1, for lossy
                   types (default 0.85)
  :type          - the MIME type of the resulting blob
                   (default "image/jpeg")
  :on-success    - called with the blob
  :on-error      - called with the error if the image can't be read or
                   encoded. When given, the promise resolves to its
                   return value; otherwise the promise rejects.
raw docstring

scaled-dimensionscljs

(scaled-dimensions width height max-dim)

Returns [width height] scaled so neither exceeds max-dim, preserving the aspect ratio. Smaller images keep their size.

Returns [width height] scaled so neither exceeds max-dim, preserving the
aspect ratio. Smaller images keep their size.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close