{"id":13636641,"url":"https://github.com/isage/lua-imagick","last_synced_at":"2026-02-13T17:58:22.321Z","repository":{"id":34767958,"uuid":"38750036","full_name":"isage/lua-imagick","owner":"isage","description":"Lua pure-c bindings to ImageMagick","archived":false,"fork":false,"pushed_at":"2024-07-25T11:28:06.000Z","size":1687,"stargazers_count":74,"open_issues_count":1,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-19T14:34:15.388Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"sarcasticat","custom":"https://paypal.me/sarcasticat"}},"created_at":"2015-07-08T11:29:24.000Z","updated_at":"2025-03-05T22:45:21.000Z","dependencies_parsed_at":"2024-07-25T13:06:26.771Z","dependency_job_id":null,"html_url":"https://github.com/isage/lua-imagick","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/isage/lua-imagick","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isage%2Flua-imagick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isage%2Flua-imagick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isage%2Flua-imagick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isage%2Flua-imagick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isage","download_url":"https://codeload.github.com/isage/lua-imagick/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isage%2Flua-imagick/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29414277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T00:01:03.622Z","updated_at":"2026-02-13T17:58:22.304Z","avatar_url":"https://github.com/isage.png","language":"Lua","funding_links":["https://patreon.com/sarcasticat","https://paypal.me/sarcasticat"],"categories":["Libraries"],"sub_categories":[],"readme":"# Lua IMagick [![Build Status](https://travis-ci.org/isage/lua-imagick.svg?branch=master)](https://travis-ci.org/isage/lua-imagick)\n\nPure-C lua bindings to ImageMagick\n\n## Why?\n\nBecause existing FFI-based bindings are hackish and buggy, duh.\n\n## Table of Contents\n\n* [FAQ](#faq)\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Usage](#usage)\n* [Examples](#examples)\n* [Authors](#authors)\n* [Copyright and License](#copyright-and-license)\n\n## FAQ\n\n1. Q) Will this work with openresty/nginx-lua?  \n   A) Yes. But remember, that IM operations **are** blocking.\n2. Q) Is this production ready?  \n   A) Yes, we're using it for couple of months now without problems.\n3. Q) Is this feature-complete?  \n   A) Hell no. There's lot of uncovered IM api. I've implemented only needed for me api for now.\n4. Q) How do i properly resize animated gif?  \n   A) Firstly, coalesce() it, then resize as usual, then optimize() it back. You really should cache coalesce()'ed image if you resizing it frequently.\n\n## Requirements\n\n* ImageMagick developer headers (\u003e=6.8.8.3)\n* Lua (5.1/5.2) or LuaJit\n* Cmake 2.8.12 or later\n* Working C compiler\n\n## Installation\n\nAs easy as  \n```bash\nmkdir build\ncd build\ncmake ..\nmake\nmake install\n```\n\nYou can also use `make unittest` after make to run tests.  \nBy default module compiles with support for luajit  \nFor other Lua interpreters see cmake options.\n\n## Usage\n\n### Synopsis\n\n```lua\nlocal magick = require \"imagick\"\n\nlocal img = magick.open(\"filename.jpg\")\nimg:set_gravity(magick.gravity[\"NorthGravity\"])\nimg:smart_resize(\"100x100^\")\nimg:extent(100, 100)\nimg:set_quality(90)\nimg:strip()\nimg:write(\"out.jpg\")\n```\n\n### Enumerations\n\n#### imagick.gravity\n\nGravity values  \nSee [here](https://imagemagick.org/api/MagickCore/geometry_8h.html#afd1e527b17eba5305ea949fa7c717069)  \nExample  \n```lua\nlocal magick = require \"imagick\"\nprint(magick.gravity[\"WestGravity\"])\n```\n\n#### imagick.interlace\n\nInterlace scheme values  \nSee [here](https://imagemagick.org/api/MagickCore/image_8h.html#af89b808293a7faf805254d1b01e69dc2)  \nExample  \n```lua\nlocal magick = require \"imagick\"\nprint(magick.interlace[\"JPEGInterlace\"])\n```\n\n#### imagick.colorspace\n\nColorspace values  \nSee [here](https://imagemagick.org/api/MagickCore/colorspace_8h.html#a5d516b430fa42c1f83b557f08128f3c2)  \n\nExample  \n```lua\nlocal magick = require \"imagick\"\nprint(magick.colorspace[\"YUVColorspace\"])\n```\n\n#### imagick.filters\n\nScale filters  \nSee [here](https://imagemagick.org/api/MagickCore/resample_8h.html#a12be80da7313b1cc5a7e1061c0c108ea)  \n\nExample  \n```lua\nlocal magick = require \"imagick\"\nprint(magick.filters[\"LanczosSharpFilter\"])\n```\n\n#### imagick.composite_op\n\nComposite operations  \nSee [here](https://imagemagick.org/api/MagickCore/composite_8h.html#a55ded0ef54def8597243db2375b987fb)  \n\nExample  \n```lua\nlocal magick = require \"imagick\"\nlocal img = magick.open(\"input.jpg\")\nlocal logo = magick.open(\"logo.jpg\")\nimg:set_compose( magick.composite_op[\"CopyCompositeOp\"] )\nimg:composite(logo, 0, 0)\nimg:write(\"out.jpg\")\n```\n\n#### imagick.font_style\n\nFont styles  \n\n* UndefinedStyle\n* NormalStyle\n* ItalicStyle\n* ObliqueStyle\n* AnyStyle\n\n#### imagick.text_align\n\nFont align  \n\n* UndefinedAlign\n* LeftAlign\n* CenterAlign\n* RightAlign\n\n#### imagick.channel\n\nColor channels  \nSee [here](https://imagemagick.org/Magick++/Enumerations.html#ChannelType)\n\n#### imagick.distort_method\n\nmethods for MagickDistortImage  \nSee [here](https://imagemagick.org/api/MagickCore/distort_8h.html#a3f53506aaaafd01ef4d52174edfce258)\n\nColor channels  \nSee [here](https://imagemagick.org/Magick++/Enumerations.html#ChannelType)\n\n### imagick functions\n\n#### `\u003cimage\u003eimage, \u003cstring\u003eerror = imagick.open(\u003cstring\u003e filepath)`\n\nOpens image from given filepath or image definition  \n\nExample  \n```lua\nlocal img = magick.open(\"input.jpg\")  -- open jpg file\n```\n\n******\n\n#### `\u003cimage\u003eimage, \u003cstring\u003eerror = imagick.open_blob(\u003cstring\u003e data)`\n\nOpen image from data blob\n\n******\n\n#### `\u003cimage\u003eimage, \u003cstring\u003eerror = imagick.open_pseudo(\u003cint\u003e width, \u003cint\u003e height, \u003cstring\u003e definition)`\n\nCreate image from pseudo-image definition. See [here](https://imagemagick.org/script/formats.php#pseudo)\n\n******\n\n### imagick image functions\n\n#### `\u003cvoid\u003e img:destroy()`\n\nManually free all allocated for image memory.  \nUse with caution. Never call to any image methods afterwards.\n\n******\n\n\n#### `\u003cint\u003ewidth =  img:width()`\n\nGet image width in pixels\n\n******\n\n#### `\u003cint\u003eheight =  img:height()`\n\nGet image height in pixels\n\n******\n\n#### `\u003cint\u003ecount =  img:count()`\n\nGet number of images inside an image (e.g. frames in GIF or pages in PDF)\n\n******\n\n#### `\u003cimage\u003eimage =  img:clone()`\n\nClone image with all current settings/values\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:write(\u003cstring\u003e filename)`\n\nWrite image to file  \n_This outputs only first frame_\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:write_all(\u003cstring\u003e filename,  \u003cbool\u003e join)`\n\nWrite all image frames to file  \nIf **join** is **false** this will create sequentaly numbered file for each image frame\nIf **join** is **true** this will create one file with all frames (this demends on image format, works with gif, for example)\n\n******\n\n#### `\u003cstring\u003edata, \u003cint\u003elenght = img:blob()`\n\nReturn raw image data as string\n\n******\n\n#### `\u003cstring\u003eformat = img:get_format()`\n\nGet image format (\"JPEG\"/\"GIF\"/\"PNG\"/etc.)\n\n******\n\n#### `\u003cbool\u003eresult, \u003cstring\u003eerror = img:set_format(\u003cstring\u003e format)`\n\nSet image format (\"JPEG\"/\"GIF\"/\"PNG\"/etc.)\n\n******\n\n#### `\u003cint\u003equality = img:get_quality()`\n\nGet image compression quality (0-100)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_quality(\u003cint\u003e quality)`\n\nSet image compression quality (0-100)\n\n******\n\n#### `\u003cint\u003egravity = img:get_gravity()`\n\nGet current image gravity\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_gravity(\u003cint\u003e gravity)`\n\nSet image gravity (See imagick.gravity enum)\n\n******\n\n#### `\u003cint\u003escheme = img:get_interlace()`\n\nGet current image interlace scheme\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_interlace(\u003cint\u003e scheme)`\n\nSet image interlace sheme (See imagick.interlace enum)  \ne.g. for Progressive JPEG set it to JPEGInterlace\n\n******\n\n#### `\u003cstring\u003evalue = img:get_option(\u003cstring\u003e name)`\n\nGet imagemagick option for image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_option(\u003cstring\u003e name, \u003cstring\u003evalue)`\n\nSet imagemagick option for image\n\n******\n\n#### `\u003cstring\u003evalue = img:get_artifact(\u003cstring\u003e name)`\n\nGet imagemagick artifact for image. See [here](https://imagemagick.org/script/command-line-options.php#define)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_artifact(\u003cstring\u003e name, \u003cstring\u003evalue)`\n\nSet imagemagick artifact for image\n\n******\n\n#### `\u003cstring\u003ecolor = img:get_bg_color()`\n\nGet image background color  \nReturns comma-separated color values.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_bg_color(\u003cstring\u003e color)`\n\nSet image background color (html hex notation or comma-separated)\n\n******\n\n#### `\u003cint\u003ecolorspace = img:get_colorspace()`\n\nGet image colorspace (See imagick.colorspace enum)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_colorspace(\u003ccolorspace\u003e colorspace)`\n\nSet image colorspace (See imagick.colorspace enum)\n\n******\n\n#### `\u003cbool\u003ealpha = img:has_alphachannel()`\n\nReturns true if image has alpha-channel\n\n******\n\n#### `\u003cbool\u003eicc = img:has_icc_profile()`\n\nReturns true if image has embedded icc profile\n\n******\n\n#### `\u003cstring\u003edata = img:get_icc_profile()`\n\nReturns image icc profile as blob\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_icc_profile(\u003cstring\u003e blob)`\n\nSet (and convert image to) image icc profile from blob\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:load_icc_profile(\u003cstring\u003e filename)`\n\nSet (and convert image to) image icc profile from file\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_compose(\u003cint\u003e compose)`\n\nSet image composite operator (See imagick.composite_op)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_font(\u003cstring\u003e path)`\n\nSet font to use in annotate, full path to font file\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_font_family(\u003cstring\u003e family)`\n\nSet font to use in annotate, font family string\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_font_size(\u003cint\u003e size)`\n  \nSet font size to use in annotate\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_font_style(\u003cint\u003e style)`\n  \nSet font style to use in annotate (See imagick.font_style enum)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_font_weight(\u003cint\u003e weight)`\n\nSet font weight to use in annotate\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_font_align(\u003cint\u003e align)`\n\nSet font align to use in annotate (See imagick.font_align enum)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:annotate(\u003cstring\u003e color, \u003cstring\u003e text, \u003cint\u003e x, \u003cint\u003e y, \u003cint\u003e angle)`\n\nAnnotate image \n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_mask(\u003cimage\u003e mask)`\n\nSet image mask for compositing operations\nYou can set it to `nil` to reset\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:coalesce()`\n\nCoalesce (rebuild) all image frames\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:optimize()`\n\nOptimise all image frames\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:deconstruct()`\n\nDeconstruct all image frames (MagickDeconstructImages() )\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:strip()`\n\nStrip exif data and profiles from image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:swirl(\u003cint\u003edegrees)`\n\nApply swirl filter\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:oilpaint(\u003cint\u003e radius)`\n\nApply oilpaint filter\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:rotate(\u003cstring\u003ecolor, \u003cdouble\u003e angle)`\n\nRotate image on angle filling empty space with color\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:modulate(\u003cdouble\u003e brightness, \u003cdouble\u003e saturation, \u003cdouble\u003e hue)`\n\nModify brightness, saturation, and hue of an image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:blur(\u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nBlur image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:flip()`\n\nCreates a vertical mirror image by reflecting the pixels around the central x-axis.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:flop()`\n\nCreates a horizontal mirror image by reflecting the pixels around the central y-axis.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:transpose()`\n\nCreates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them 90-degrees.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:transverse  ()`\n\nCreates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them 270-degrees.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:sharpen(\u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nSharpen image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:adaptive_blur(\u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nBlur image adaptively\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:adaptive_sharpen(\u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nSharpen image adaptively\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:blur_channel(\u003cchannel\u003e channel, \u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nBlur image channel\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:sharpen_channel(\u003cchannel\u003e channel, \u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nSharpen image channel\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:adaptive_blur_channel(\u003cchannel\u003e channel, \u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nBlur image channel adaptively\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:adaptive_sharpen_channel(\u003cchannel\u003e channel, \u003cdouble\u003e sigma, \u003cdouble\u003e radius)`\n\nSharpen image channel adaptively\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:gamma(\u003cdouble\u003e gamma)`\n\nModify image gamma\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:gamma_channel(\u003cdouble\u003e gamma, \u003cchannel\u003e channel)`\n\nModify image channel gamma\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:auto_gamma()`\n\nAuto-adjust image gamma\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:auto_gamma_channel(\u003cchannel\u003e channel)`\n\nAuto-adjust image channel gamma\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:level(\u003cdouble\u003e black, \u003cdouble\u003e white, \u003cdouble\u003e gamma)`\n\nAdjust image levels. Black/white points is 0-100%\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:level_channel(\u003cdouble\u003e black, \u003cdouble\u003e white, \u003cdouble\u003e gamma, \u003cchannel\u003e channel)`\n\nAdjust image levels for channel. Black/white points is 0-100%\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:contrast(\u003cbool\u003e sharpen)`\n\nEnhances the intensity differences between the lighter and darker elements of the image.  \nSet sharpen to 'true' to increase the image contrast, otherwise the contrast is reduced\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:border(\u003cstrinng\u003e color, \u003cint\u003e width, \u003cint\u003e height)`\n\nSurrounds the image with a border of the color\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:colorize(\u003cstring\u003e color, \u003cdouble\u003e opacity)`\n\nBlends the fill color with each pixel in the image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:resize(\u003cint\u003ewidth, \u003cint\u003e height)`\n\nResize image using current scale filter\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:adaptive_resize(\u003cint\u003ewidth, \u003cint\u003e height)`\n\nAdaptively resize image with data dependent triangulation using current image filter\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:resample(\u003cint\u003ewidth, \u003cint\u003e height, \u003cint\u003e filter, \u003cdouble\u003e blur)`\n\nResample image. See [https://imagemagick.org/api/magick-image.php#MagickResampleImage](https://imagemagick.org/api/magick-image.php#MagickResampleImage)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:scale(\u003cint\u003e width, \u003cint\u003e height)`\n\nFast scale image \n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:crop(\u003cint\u003e width, \u003cint\u003e height)`\n\nCrop image\nYou can pass additional x,y coordinates, e.g.: `\u003cbool\u003estatus, \u003cstring\u003eerror = img:crop(\u003cint\u003e width, \u003cint\u003e height, \u003cint\u003e x, \u003cint\u003e y)`\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:thumbnail(\u003cint\u003e width, \u003cint\u003e height)`\n\nResize image and remove all profiles.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:composite(\u003cimage\u003e src, \u003cint\u003e x, \u003cint\u003e y, \u003cint\u003e compositeop)`\n\nApply one image on top of another at x/y with composite operator compositeop (See imagick.composite_op)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:composite_channel(\u003cimage\u003e src, \u003cchannel\u003e channel, \u003cint\u003e x, \u003cint\u003e y, \u003cint\u003e compositeop)`\n\nApply one image channel on top of another at x/y with composite operator compositeop (See imagick.composite_op)\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:extent(\u003cint\u003e width, \u003cint\u003e height)`\n\nExtent image\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:smart_resize(\u003cstring\u003e size)`\n\nSmartly resize image.  \nFormat is one of:\n* WxH (Keep aspect-ratio, use higher dimension)\n* WxH^ (Keep aspect-ratio, use lower dimension (crop))\n* WxH! (Ignore aspect-ratio)\n\nIt uses Mitchell filter for upscaling/downscaling all formats and Lanczos for downscaling JPEG.  \n\nYou should use img:extent after it to really crop or add borders (with `img:get_bg_color()`) to image.\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_fill_color(\u003cstring\u003e color)`\n\nSet DrawingWand fill color\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:set_stroke_color(\u003cstring\u003e color)`\n\nSet DrawingWand stroke color\n\n******\n\n#### `img:query_metrics(\u003cstring\u003e text)`\n\nQuery font metrics. See https://imagemagick.org/api/magick-wand.php#MagickQueryFontMetrics\nReturns 13 \u003cdouble\u003e variables or nil,\u003cstring\u003eerror\n\n******\n\n#### `img:query_multiline_metrics(\u003cstring\u003e text)`\n\nQuery font metrics. See https://imagemagick.org/api/magick-wand.php#MagickQueryMultilineFontMetrics\nReturns 13 \u003cdouble\u003e variables or nil,\u003cstring\u003eerror\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:distort(\u003cdistort_method\u003e method, \u003carray\u003e params, \u003cbool\u003e bestfit)`\n\nDistorts image. See https://imagemagick.org/api/magick-image.php#MagickDistortImage  \nExample (https://imagemagick.org/Usage/distorts/#arc):  \n```lua\nlocal magick = require \"imagick\"\nlocal img = magick.open(\"rose.jpg\")\n\nimg:distort(magick.distort_method[\"ArcDistortion\"], { 60, 90 }, false)\nimg:write(\"out.jpg\")\n\n```\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:threshold(\u003cint\u003e value)`\n\nApply simultaneous black/white threshold to the image.  \nSee https://imagemagick.org/api/magick-image.php#MagickThresholdImage  \nSee https://imagemagick.org/script/command-line-options.php#threshold  \n  \n`value` is effective between `0` and `0xffff`\n```lua\nlocal magick = require \"imagick\"\nlocal img = magick.open(\"rose.jpg\")\n\n---Converts percents to value\nfunction pct(pct)\n  return 65535 * pct / 100\nend\n\nimg:threshold(pct(95))\nimg:write(\"out.jpg\")\n\n```\n\n******\n\n#### `\u003cbool\u003estatus, \u003cstring\u003eerror = img:trim(\u003cint\u003e fuzz)`\n\nTrim an image.  \nThis option removes any edges that are exactly the same color as the corner pixels. Use fuzz to make trim remove edges that are nearly the same color as the corner pixels.  \nSee https://imagemagick.org/api/magick-image.php#MagickTrimImage  \nSee https://imagemagick.org/script/command-line-options.php#trim  \n  \n`fuzz` is effective between `0` and `0xffff`\n```lua\nlocal magick = require \"imagick\"\nlocal img = magick.open(\"rose.jpg\")\n\n---Converts percents to value\nfunction pct(pct)\n  return 65535 * pct / 100\nend\n\nimg:trim(pct(5))\nimg:write(\"out.jpg\")\n\n```\n\n******\n\n## Examples\n\n### Captcha\n```lua\nlocal magick = require \"imagick\"\n\nlocal code =\"hello\"\n\nlocal i = 0\nmath.randomseed(os.time())\nlocal r=100+math.random(35)\nlocal g=100+math.random(35)\nlocal b=100+math.random(35)\n\n\nlocal img = assert(magick.open_pseudo(150,50, \"xc:rgb(\"..r..\",\"..g..\",\"..b..\")\"))\n\nfor c in code:gmatch(\".\") do\n  local r=150+math.random(105)\n  local g=150+math.random(105)\n  local b=150+math.random(105)\n  img:set_font_size(25+math.random(10))\n  img:annotate(\"rgb(\"..r..\",\"..g..\",\"..b..\")\", c, (i*20)+10, math.random(50-50)+30, math.random(55)-20)\n  i=i+1\nend\n\nimg:swirl(10)\nimg:oilpaint(1)\nimg:write(\"captcha.png\")\n\n```\n\n### Simple filters\n\n#### Gotham\n```lua\nlocal ima = require(\"imagick\")\n\nlocal img, err = ima.open(\"input.jpg\")\nimg:modulate(120, 10 ,100)\nimg:colorize(\"#222b6d\", 0.2)\nimg:gamma(0.5)\nimg:contrast(true)\nimg:contrast(true)\nimg:border('black', 20, 20)\n\nimg:write(\"out.jpg\")\n\n```\n\n#### Lomo\n```lua\nlocal ima = require(\"imagick\")\n\nlocal img, err = ima.open(\"input.jpg\")\nimg:level_channel(33, 66, 1.0, ima.channel[\"RedChannel\"])\nimg:level_channel(33, 66, 1.0, ima.channel[\"GreenChannel\"])\n\ncrop_x = math.floor(img:width() * 1.5)\ncrop_y = math.floor(img:height() * 1.5)\n\nlocal gradient = ima.open_pseudo(crop_x, crop_y, \"radial-gradient:none-black\")\n\ngradient:set_gravity(ima.gravity['CenterGravity'])\ngradient:crop(img:width(), img:height())\nimg:composite(gradient, 0, 0, ima.composite_op['MultiplyCompositeOp'])\n\nimg:border('black', 20, 20)\n\nimg:write(\"out.jpg\")\n\n```\n\n\n## Authors\n\nEpifanov Ivan \u003cisage.dna@gmail.com\u003e\n\n[Back to TOC](#table-of-contents)\n\n## Copyright and License\n\nThis module is licensed under the WTFPL license.  \n(See LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisage%2Flua-imagick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisage%2Flua-imagick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisage%2Flua-imagick/lists"}