thumbnail image generator.
- Imlib2
luarocks install --from=http://mah0x211.github.io/rocks/ thumbnail
or
git clone https://github.com/mah0x211/lua-thumbnail.git
cd lua-thumbnail
luarocks make
these constants defined at the thumbnail.*
for parameter of saveCrop/saveAspect methods
- LEFT
- CENTER
- RIGHT
- TOP
- MIDDLE
- BOTTOM
these function create the image object.
Parameters
- filepath: path string to image file.
Returns
- image: image object.
- err: error string on failure.
raw data value must be 32-bit per pixel.
Parameters
- width: image width.
- height: image height.
- rawdata: image raw data (light userdata).
Returns
- image: image object.
- err: error string on failure.
these method returns immutable values.
Returns
- rawdata: image raw data (light userdata).
- bytes: data size.
Returns
- width: image width.
- height: image height.
this method will deallocate memory of rawdata immediately.
after calling this method, the image object can no longer be used.
following methods are returned values of current export option.
you could change these values by passing the arguments of these value.
following parameters must be larger than 0.
Parameters
- width: image width
- height: image height
Returns
- width: image width
- height: image height
following parameters must be range of 0 to 100.
Parameters
- quality: image quality.
Returns
- quality: image quality.
following parameter must be image format string supported by imlib2 library.
e.g. jpg
, png
Note: it is set 'png' by default if the image objects created by thumbnail.read function.
Parameters
- format: image format string.
Returns
- format: image format string.
save stretched image.
Parameters
- path: destination path of the image.
Returns
- err: nil on success, or error string on failure.
save image with maintain aspect ratio after cutting margin.
Parameters
- path: destination path of the image.
Returns
- err: nil on success, or error string on failure.
save cropped image with maintain aspect ratio.
Parameters
- path: destination path of the image.
- halign: horizontal alignment. (default: CENTER)
- valign: vertical alignment. (default: MIDDLE)
Returns
- err: nil on success, or error string on failure.
save image with maintain aspect ratio.
Parameters
- path: destination path of the image.
- h: hue of background color. (0-360)
- s: saturation of background color. (0-1)
- l: lightness of background color. (0-1)
- a: alpha of background color. (0-255)
- halign: horizontal alignment. (default: CENTER)
- valign: vertical alignment. (default: MIDDLE)
Returns
- err: nil on success, or error string on failure.