(circle image)
Crop a circle from an image, leaving a transparent background. This function does not compose well with other functions that cut from the image, as its implementation doesn't really cut - it paints parts of the image onto a circle. If you need to compose circles with other shapes, create the circle first.
Why must this function be so limited? Using a clip path yields a much too jagged circle. Instead we paint a beautifully anti-aliased circle, and then composit the image on top. This yields a pleasantly anti-aliased circle image with the drawback that if you apply the transformation to a transparent image, you will see the parts of the white circle the image doesn't cover.
Crop a circle from an image, leaving a transparent background. This function does not compose well with other functions that cut from the image, as its implementation doesn't really cut - it paints parts of the image onto a circle. If you need to compose circles with other shapes, create the circle first. Why must this function be so limited? Using a clip path yields a much too jagged circle. Instead we paint a beautifully anti-aliased circle, and then composit the image on top. This yields a pleasantly anti-aliased circle image with the drawback that if you apply the transformation to a transparent image, you will see the parts of the white circle the image doesn't cover.
(crop image x y width height)
Crops an image.
x, y
are the coordinates to top left corner of the area to crop.
width, height
are the width and height of the area to crop.
The returned image does not share its data with the original image.
Crops an image. `x, y` are the coordinates to top left corner of the area to crop. `width, height` are the width and height of the area to crop. The returned image does not share its data with the original image.
(duotone image from to)
Create a duotone image. A duotone image is like a grayscale image, but instead of mapping each pixel to the range black/white, it maps the pixels along the gradient of an arbitrary from color to an arbitrary to color - e.g. from red to blue. See samples at https://duotones.co
from
and to
are colors as vectors of R G B, and optionally Alpha values in
the range 0-255. The alpha channel can be omitted, in which case it will be
set to 255 if required by the image (e.g., if it is an ARGB image).
Create a duotone image. A duotone image is like a grayscale image, but instead of mapping each pixel to the range black/white, it maps the pixels along the gradient of an arbitrary from color to an arbitrary to color - e.g. from red to blue. See samples at https://duotones.co `from` and `to` are colors as vectors of R G B, and optionally Alpha values in the range 0-255. The alpha channel can be omitted, in which case it will be set to 255 if required by the image (e.g., if it is an ARGB image).
(duotone-filter raster from to)
Actually apply the duotone filter to the raster. This function uses a tight loop over the pixels in the image, and is very performance sensitive. If attempting to refactor/simplify this function, benchmark your efforts before and after, as it is very easy to trigger reflection and/or boxing, which causes abysmal performance.
Actually apply the duotone filter to the raster. This function uses a tight loop over the pixels in the image, and is _very_ performance sensitive. If attempting to refactor/simplify this function, benchmark your efforts before and after, as it is very easy to trigger reflection and/or boxing, which causes abysmal performance.
(flip image direction)
Flips an image.
If direction is :horizontal
, flips the image around the y-axis.
If direction is :vertical
, flips the image around the x-axis.
Flips an image. If direction is `:horizontal`, flips the image around the y-axis. If direction is `:vertical`, flips the image around the x-axis.
(grayscale image)
Convert an image to grayscale.
Convert an image to grayscale.
(normalise-angle theta)
Restrict the rotation angle to the range [-360..360].
Restrict the rotation angle to the range [-360..360].
(paste image & layer-defs)
Pastes layer(s) onto image at coordinates x
and y
.
layer-defs
is expected to in the format
[layer1 x1 y2 layer2 x2 y2 ... ]
Layers are loaded using fivetonine.collage.util/load-image
.
Top left corner of a layer will be at x, y
.
Throws IllegalArgumentException
if the number of elements in the list of
layers and coordinates is not divisible by 3.
Returns the resulting image.
Pastes layer(s) onto image at coordinates `x` and `y`. `layer-defs` is expected to in the format [layer1 x1 y2 layer2 x2 y2 ... ] Layers are loaded using `fivetonine.collage.util/load-image`. Top left corner of a layer will be at `x, y`. Throws `IllegalArgumentException` if the number of elements in the list of layers and coordinates is not divisible by 3. Returns the resulting image.
(paste* base [layer x y])
Paste layer on top of base at position x, y
and return the resulting image.
Used as an internal function by paste
.
Paste layer on top of base at position `x, y` and return the resulting image. Used as an internal function by `paste`.
(resize image & {:keys [width height] :as opts})
Resizes an image.
If only width
or height
is provided, the resulting image will be width
or height
px wide, respectively. The other dimension will be calculated
automatically to preserve width/height
ratio.
With width
and height
both provided, the resulting image will be crudely
resized to match the provided values.
If neither width
nor height
are provided, IllegalArgumentException
is
thrown.
Examples:
(resize image :width 100) (resize image :height 300) (resize image :width 100 :height 300)
Resizes an image. If only `width` or `height` is provided, the resulting image will be `width` or `height` px wide, respectively. The other dimension will be calculated automatically to preserve `width/height` ratio. With `width` and `height` both provided, the resulting image will be crudely resized to match the provided values. If neither `width` nor `height` are provided, `IllegalArgumentException` is thrown. Examples: (resize image :width 100) (resize image :height 300) (resize image :width 100 :height 300)
(resize* image width height)
Resize the given image to width
and height
.
Used as an internal function by resize
.
Note: the method of resizing may change in the future as there are better, iterative, solutions to balancing speed vs. quality. See the perils of Image.getScaledInstance().
Resize the given image to `width` and `height`. Used as an internal function by `resize`. Note: the method of resizing may change in the future as there are better, iterative, solutions to balancing speed vs. quality. See [the perils of Image.getScaledInstance()](https://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html).
(rotate image theta)
Rotates image through angle theta
, where theta
is
an integer multiple of 90.
If theta > 0
, the image is rotated clockwise.
If theta < 0
, the image is rotated anticlockwise.
Rotates image through angle `theta`, where `theta` is an integer multiple of 90. If `theta > 0`, the image is rotated clockwise. If `theta < 0`, the image is rotated anticlockwise.
(scale image f)
Scales an image by a factor f
.
If 0.0 < f < 1.0
the image is scaled down.
If f > 1.0
the image is scaled up.
Scales an image by a factor `f`. If `0.0 < f < 1.0` the image is scaled down. If `f > 1.0` the image is scaled up.
(triangle image & [{:keys [position]}])
Crop a triangle from an image, leaving a transparent background. Can optionally be called with an option map that specifies where the triangle is positioned:
(triangle image {:position :upper-left})
(triangle image {:position :lower-left})
(triangle image {:position :lower-right})
(triangle image {:position :upper-right})
Crop a triangle from an image, leaving a transparent background. Can optionally be called with an option map that specifies where the triangle is positioned: ```clj (triangle image {:position :upper-left}) (triangle image {:position :lower-left}) (triangle image {:position :lower-right}) (triangle image {:position :upper-right}) ```
(with-image image-resource & operations)
A helper for applying multiple operations to an image.
image-resource
can be a String
, a File
or a BufferedImage
.
Example:
(with-image "/path/to/image.jpg" (scale 0.8) (rotate 90) (crop 0 0 100 100))
Expands to (properly namespaced):
(let [image__2336__auto__ (load-image "/path/to/image.jpg")] (clojure.core/-> image__2336__auto__ (scale 0.8) (rotate 90) (crop 0 0 100 100)))
Returns the image which is the result of applying all operations to the input image.
A helper for applying multiple operations to an image. `image-resource` can be a `String`, a `File` or a `BufferedImage`. Example: (with-image "/path/to/image.jpg" (scale 0.8) (rotate 90) (crop 0 0 100 100)) Expands to (properly namespaced): (let [image__2336__auto__ (load-image "/path/to/image.jpg")] (clojure.core/-> image__2336__auto__ (scale 0.8) (rotate 90) (crop 0 0 100 100))) Returns the image which is the result of applying all operations to the input image.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close