Module: lib-tde.imagemagic
Lua wrapper around imagemagic.
This module exposes the imagemagic api. However it is far from complete If some functionality is missing please create a ticket in github or merge a PR Imagemagic is extensive and this module only implements what we use in TDE
Some images that the user provide are way to large and consume to much resources This can be solved by creating a "thumbnail" of the image, the syntax looks as followed
-- scale the image to 300x200 pixels and store it in out.png lib-tde.imagemagic.scale("file.png", 300, 200, "out.png", function() print("Finished scaling image") end)
Info:
- Copyright: 2020 Tom Meyers
- Author: Tom Meyers
Static module functions
lib-tde.imagemagic.scale (string, number, number, string, function) | Scale an image to a specific size | |
lib-tde.imagemagic.grayscale (string, string, function) | Convert your image to be grayscale | |
lib-tde.imagemagic.transparent (string, string, string, function) | Make a color in an image transparent | |
lib-tde.imagemagic.compress (string, string, number, function) | Compress an image to save disk space and memory consumption | |
lib-tde.imagemagic.convert (string, string, function) | Convert from one image type to another |
Static module functions
- lib-tde.imagemagic.scale (string, number, number, string, function)
-
Scale an image to a specific size
Parameters:
- string output The path where you want to save the scaled image to
- number height The height of the scaled image in pixels
- number height The height of the scaled image in pixels
- string output The path where you want to save the scaled image to
- function callback The function to trigger when the image is scaled
Usage:
lib-tde.imagemagic.scale("file.png", 300, 200, "out.png", function() print("Finished scaling image") end)
- lib-tde.imagemagic.grayscale (string, string, function)
-
Convert your image to be grayscale
Parameters:
- string output The path where you want to save the grayscaled image to
- string output The path where you want to save the grayscaled image to
- function callback The function to trigger when the image is generated
Usage:
lib-tde.imagemagic.grayscale("file.png", "gray.png", function() print("Finished generating a grayscale image") end)
- lib-tde.imagemagic.transparent (string, string, string, function)
-
Make a color in an image transparent
Parameters:
- string color The color to make transparent in hex
- string color The color to make transparent in hex
- string color The color to make transparent in hex
- function callback The function to trigger when the image is made transparent
Usage:
lib-tde.imagemagic.transparent("file.png", "out.png", "#FFFFFF", function() print("Finished making the image transparent") end)
- lib-tde.imagemagic.compress (string, string, number, function)
-
Compress an image to save disk space and memory consumption
Parameters:
- string output The path where you want to save the compressed image to
- string output The path where you want to save the compressed image to
- number rate The amount of quality to keep in percentage
- function callback The function to trigger when the image is compressed
Usage:
lib-tde.imagemagic.compress("file.png", "out.png", 85, function() print("Finished compressing image") end)
- lib-tde.imagemagic.convert (string, string, function)
-
Convert from one image type to another
Parameters:
- string output The path where you want to save the new image to
- string output The path where you want to save the new image to
- function callback The function to trigger when the image is converted
Usage:
lib-tde.imagemagic.convert("file.png", "file.jpg", function() print("Finished converting image") end)