Main namespace for imagez image processing functionality
Main namespace for imagez image processing functionality
(copy src)
(copy src factor-or-shape)
(copy src target-width target-height)
Copies an image to a new BufferedImage.
May optionally specify the target image dimensions, or a resizing factor. Resizing during copy does not perform any interpolation: use scale instead if this is desired.
Copies an image to a new BufferedImage. May optionally specify the target image dimensions, or a resizing factor. Resizing during copy does *not* perform any interpolation: use scale instead if this is desired.
(ensure-default-image-type image)
If the provided image is does not have the default image type (BufferedImage/TYPE_INT_ARGB) a copy with that type is returned.
If the provided image is does not have the default image type (BufferedImage/TYPE_INT_ARGB) a copy with that type is returned.
(fill! image colour)
Fills the image with a specified ARGB value or Java Color. Mutates the image.
Fills the image with a specified ARGB value or Java Color. Mutates the image.
(fill-rect! image x y w h colour)
Fills a rectangle on the image with a specified ARGB value or Java Color. Mutates the image.
Fills a rectangle on the image with a specified ARGB value or Java Color. Mutates the image.
(filter-image image filter)
Applies a filter to a source image. Filter may be either a BufferedImageOp or an Imagez filter.
Returns a new image.
Applies a filter to a source image. Filter may be either a BufferedImageOp or an Imagez filter. Returns a new image.
(flip image direction)
Flips an image in the specified direction :horizontal or :vertical
Flips an image in the specified direction :horizontal or :vertical
(get-pixel image x y)
Gets a single pixel in a BufferedImage.
Gets a single pixel in a BufferedImage.
(get-pixels image)
Gets the pixels in a BufferedImage as a primitive int[] array. This is often an efficient format for manipulating an image.
Gets the pixels in a BufferedImage as a primitive int[] array. This is often an efficient format for manipulating an image.
(gradient-image spectrum-fn)
(gradient-image spectrum-fn w h)
Creates an image filled with a gradient according to the given spectrum function. Default is a filled gradient from left=0 to right=1.
Creates an image filled with a gradient according to the given spectrum function. Default is a filled gradient from left=0 to right=1.
(graphics image)
Gets the Java Graphics2D object associated with an image
Gets the Java Graphics2D object associated with an image
(height image)
Gets the height of an image as a long value
Gets the height of an image as a long value
(load-image resource)
Loads a BufferedImage from a string, file or a URL representing a resource on the classpath.
Usage:
(load-image "/some/path/to/image.png") ;; (require [clojure.java.io :refer [resource]]) (load-image (resource "some/path/to/image.png"))
Loads a BufferedImage from a string, file or a URL representing a resource on the classpath. Usage: (load-image "/some/path/to/image.png") ;; (require [clojure.java.io :refer [resource]]) (load-image (resource "some/path/to/image.png"))
(load-image-resource res-path)
Loads an image from a named resource on the classpath.
Equivalent to (load-image (clojure.java.io/resource res-path))
Loads an image from a named resource on the classpath. Equivalent to (load-image (clojure.java.io/resource res-path))
(new-image width height)
(new-image width height alpha?)
Creates a new BufferedImage with the specified width and height. Uses BufferedImage/TYPE_INT_ARGB format by default, but also supports BufferedImage/TYPE_INT_RGB when alpha channel is not needed.
Creates a new BufferedImage with the specified width and height. Uses BufferedImage/TYPE_INT_ARGB format by default, but also supports BufferedImage/TYPE_INT_RGB when alpha channel is not needed.
(resize image new-width)
(resize image new-width new-height)
Resizes an image to the specified width and height. If height is omitted, maintains the aspect ratio.
Resizes an image to the specified width and height. If height is omitted, maintains the aspect ratio.
(rotate image degrees)
Rotate an image clockwise by x degrees
Rotate an image clockwise by x degrees
(save image
path
&
{:keys [quality progressive] :or {quality 0.8 progressive nil} :as opts})
Stores an image to disk.
See the documentation of mikera.image.core/write
for optional arguments.
Examples:
(save image "/path/to/new/image.jpg" :quality 1.0) (save image "/path/to/new/image/jpg" :progressive false) (save image "/path/to/new/image/jpg" :quality 0.7 :progressive true)
Returns the path to the saved image when saved successfully.
Stores an image to disk. See the documentation of `mikera.image.core/write` for optional arguments. Examples: (save image "/path/to/new/image.jpg" :quality 1.0) (save image "/path/to/new/image/jpg" :progressive false) (save image "/path/to/new/image/jpg" :quality 0.7 :progressive true) Returns the path to the saved image when saved successfully.
(scale image factor)
(scale image width-factor height-factor)
Scales an image by a given factor or ratio.
Scales an image by a given factor or ratio.
(scale-image image new-width new-height)
DEPRECATED: use 'resize' instead
DEPRECATED: use 'resize' instead
(set-pixel image x y rgb)
Sets a single pixel in a BufferedImage.
Sets a single pixel in a BufferedImage.
(set-pixels image pixels)
Sets the pixels in a BufferedImage using a primitive int[] array. This is often an efficient format for manipulating an image.
Sets the pixels in a BufferedImage using a primitive int[] array. This is often an efficient format for manipulating an image.
(show image & {:keys [zoom resize title]})
Displays an image in a new frame.
The frame includes simple menus for saving an image, and other handy utilities.
Options can be supplied in keyword arguments as follows: :zoom - zoom the image by a specified factor, e.g. 2.0. Performs smoothing :resize - resizes the image by either a specified factor or to a given target shape e.g. [256 256] :title - specifies the title of the resulting frame
Displays an image in a new frame. The frame includes simple menus for saving an image, and other handy utilities. Options can be supplied in keyword arguments as follows: :zoom - zoom the image by a specified factor, e.g. 2.0. Performs smoothing :resize - resizes the image by either a specified factor or to a given target shape e.g. [256 256] :title - specifies the title of the resulting frame
(sub-image image x y w h)
Gets a sub-image area from an image.
Gets a sub-image area from an image.
(width image)
Gets the width of an image as a long value
Gets the width of an image as a long value
(write image
out
format-name
&
{:keys [quality progressive] :or {quality 0.8 progressive nil}})
Writes an image externally.
out
will be coerced to a java.io.OutputStream
as per clojure.java.io/output-stream
.
format-name
determines the format of the written file. See
ImageIO/getImageWritersByFormatName
Accepts optional keyword arguments.
:quality
- decimal, between 0.0 and 1.0. Defaults to 0.8.
:progressive
- boolean, true
turns progressive encoding on, false
turns it off. Defaults to the default value in the ImageIO API -
ImageWriteParam/MODE_COPY_FROM_METADATA
. See
Java docs.
Examples:
(write image (clojure.java.io/resource "my/image.png") "png" :quality 1.0) (write image my-output-stream "jpg" :progressive false) (write image "/path/to/new/image/jpg" "jpg" :quality 0.7 :progressive true)
Writes an image externally. `out` will be coerced to a `java.io.OutputStream` as per `clojure.java.io/output-stream`. `format-name` determines the format of the written file. See [ImageIO/getImageWritersByFormatName](https://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageIO.html#getImageWritersByFormatName(java.lang.String)) Accepts optional keyword arguments. `:quality` - decimal, between 0.0 and 1.0. Defaults to 0.8. `:progressive` - boolean, `true` turns progressive encoding on, `false` turns it off. Defaults to the default value in the ImageIO API - `ImageWriteParam/MODE_COPY_FROM_METADATA`. See [Java docs](http://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageWriteParam.html). Examples: (write image (clojure.java.io/resource "my/image.png") "png" :quality 1.0) (write image my-output-stream "jpg" :progressive false) (write image "/path/to/new/image/jpg" "jpg" :quality 0.7 :progressive true)
(zoom image factor)
Zooms into (scales) an image with a given scale factor.
Zooms into (scales) an image with a given scale factor.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close