#
hs.image
A module for capturing and manipulating image objects from other modules for use with hs.drawing.
#
API Overview
Constants - Useful values which cannot be changed
additionalImageNames systemImageNames
Functions - API calls offered directly by the extension
getExifFromPath
Constructors - API calls which return an object, typically one that offers API methods
iconForFile iconForFileType imageFromAppBundle imageFromASCII imageFromMediaFile imageFromName imageFromPath imageFromURL
Methods - API calls which can only be made on an object returned by a constructor
bitmapRepresentation colorAt copy croppedCopy encodeAsURLString getLoupedeckArray name saveToFile setName setSize size template toASCII
#
API Documentation
#
Constants
#
additionalImageNames
#
systemImageNames
#
Functions
#
getExifFromPath
#
Constructors
#
iconForFile
#
iconForFileType
#
imageFromAppBundle
#
imageFromASCII
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.image.imageFromASCII(ascii[, context]) -> object
|
| Type | Constructor |
| Description | Creates an image from an ASCII representation with the specified context. |
| Parameters |
- ascii - A string containing a representation of an image
- context - An optional table containing the context for each shape in the image. A shape is considered a single drawing element (point, ellipse, line, or polygon) as defined at https://github.com/cparnot/ASCIImage and http://cocoamine.net/blog/2015/03/20/replacing-photoshop-with-nsstring/. The context table is an optional (possibly sparse) array in which the index represents the order in which the shapes are defined. The last (highest) numbered index in the sparse array specifies the default settings for any unspecified index and any settings which are not explicitly set in any other given index. Each index consists of a table which can contain one or more of the following keys:fillColor - the color with which the shape will be filled (defaults to black) Color is defined in a table containing color component values between 0.0 and 1.0 for each of the keys:red (default 0.0)green (default 0.0)blue (default 0.0)alpha (default 1.0)strokeColor - the color with which the shape will be stroked (defaults to black)lineWidth - the line width (number) for the stroke of the shape (defaults to 1 if anti-aliasing is on or (√2)/2 if it is off -- approximately 0.7)shouldClose - a boolean indicating whether or not the shape should be closed (defaults to true)antialias - a boolean indicating whether or not the shape should be antialiased (defaults to true)
- An
hs.image
object, or nil if an error occurred
- To use the ASCII diagram image support, see https://github.com/cparnot/ASCIImage and http://cocoamine.net/blog/2015/03/20/replacing-photoshop-with-nsstring
- The default for lineWidth, when antialiasing is off, is defined within the ASCIImage library. Geometrically it represents one half of the hypotenuse of the unit right-triangle and is a more accurate representation of a "real" point size when dealing with arbitrary angles and lines than 1.0 would be.
#
imageFromMediaFile
#
imageFromName
#
imageFromPath
#
imageFromURL
#
Methods
#
bitmapRepresentation
#
colorAt
#
copy
#
croppedCopy
#
encodeAsURLString
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.image:encodeAsURLString([scale], [type]) -> string
|
| Type | Method |
| Description | Returns a bitmap representation of the image as a base64 encoded URL string |
| Parameters |
- scale - an optional boolean, default false, which indicates that the image size (which macOS represents as points) should be scaled to pixels. For images that have Retina scale representations, this may result in an encoded image which is scaled down from the original source.
- type - optional case-insensitive string parameter specifying the bitmap image type for the encoded string (default PNG) PNG - save in Portable Network Graphics (PNG) format TIFF - save in Tagged Image File Format (TIFF) format BMP - save in Windows bitmap image (BMP) format GIF - save in Graphics Image Format (GIF) format JPEG - save in Joint Photographic Experts Group (JPEG) format
- the bitmap image representation as a Base64 encoded string
- You can convert the string back into an image object with
hs.image.imageFromURL , e.g.hs.image.imageFromURL(string)
#
getLoupedeckArray
#
name
#
saveToFile
| | |
| --------------------------------------------|-------------------------------------------------------------------------------------|
| Signature | hs.image:saveToFile(filename, [scale], [filetype]) -> boolean
|
| Type | Method |
| Description | Save the hs.image object as an image of type filetype
to the specified filename. |
| Parameters |
- filename - the path and name of the file to save.
- scale - an optional boolean, default false, which indicates that the image size (which macOS represents as points) should be scaled to pixels. For images that have Retina scale representations, this may result in a saved image which is scaled down from the original source.
- filetype - optional case-insensitive string parameter specifying the file type to save (default PNG) PNG - save in Portable Network Graphics (PNG) format TIFF - save in Tagged Image File Format (TIFF) format BMP - save in Windows bitmap image (BMP) format GIF - save in Graphics Image Format (GIF) format JPEG - save in Joint Photographic Experts Group (JPEG) format
- Status - a boolean value indicating success (true) or failure (false)
- Saves image at the size in points (or pixels, if
scale
is true) as reported byhs.image:size() for the image object