{"id":26746702,"url":"https://github.com/processone/eimp","last_synced_at":"2025-04-13T05:00:09.845Z","repository":{"id":25069740,"uuid":"103098868","full_name":"processone/eimp","owner":"processone","description":"Erlang Image Manipulation Process","archived":false,"fork":false,"pushed_at":"2025-03-27T14:47:50.000Z","size":3700,"stargazers_count":48,"open_issues_count":1,"forks_count":20,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-13T04:59:50.701Z","etag":null,"topics":["erlang","image-processing"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/processone.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-09-11T06:34:44.000Z","updated_at":"2025-03-27T14:47:46.000Z","dependencies_parsed_at":"2025-01-07T11:33:39.121Z","dependency_job_id":"46518fef-0d70-4e35-8311-d95aaedae9c4","html_url":"https://github.com/processone/eimp","commit_stats":{"total_commits":103,"total_committers":9,"mean_commits":"11.444444444444445","dds":0.6407766990291262,"last_synced_commit":"ec616de3762ce8498856b4fdadf8ba36045c6773"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Feimp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Feimp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Feimp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Feimp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/processone","download_url":"https://codeload.github.com/processone/eimp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665756,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["erlang","image-processing"],"created_at":"2025-03-28T09:15:09.287Z","updated_at":"2025-04-13T05:00:09.805Z","avatar_url":"https://github.com/processone.png","language":"Erlang","readme":"Erlang Image Manipulation Process\n=================================\n\n[![CI](https://github.com/processone/eimp/actions/workflows/ci.yml/badge.svg)](https://github.com/processone/eimp/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/processone/eimp/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/processone/eimp?branch=master)\n[![Hex version](https://img.shields.io/hexpm/v/eimp.svg \"Hex version\")](https://hex.pm/packages/eimp)\n\n`eimp` is an Erlang/Elixir application for manipulating graphic images using\nexternal C libraries. It supports WebP, JPEG, PNG and GIF.\n\n# Requirements\n\n- GNU Make\n- GCC\n- Erlang/OTP 17 and higher\n- libgd\n- libwebp\n- libpng\n- libjpeg\n\n**NOTE**: It's hard to say which versions of the C libraries are required,\nbut it seems like not too old versions should work well.\n\n# Install\n\n```\n$ ./configure\n$ make\n```\n\nNote that running the configure script is highly recommended, so you should consider\nadding it in pre-hooks of your rebar configuration.\n\nIf no C libraries are found at compile time, the package will still be compiled.\nIn this case the only usable function would be [get_type/1](#get_type1).\n\n# Application design\n\nThe C code is compiled into external native binary called `eimp`, which is\nconnected to Erlang VM using an external port. This is done because used C libraries\nare known not to be extremely stable, thus, if you wrap them into the emulator\nusing a driver or NIF, they can crash the whole emulator.\n\nWhen being loaded, the application starts a single `eimp` process per CPU core\nand uses a round-robin pool to schedule tasks to them. Simple recovery mechanisms\nare also supported:\n- if a request to `eimp` process has failed, next `eimp` process in the pool is picked,\n  until the pool is exhausted\n- if an `eimp` process is dead, it will be restarted automatically\n- an `eimp` process is protected against decompression bombs\n\n# Usage\n\nBefore using the application you should start it with either `eimp:start()` or\n`application:start(eimp)`.\n\n# API\n\nCurrent API is simple and supports only a few functions:\n\n### convert/2\n```erl\n-spec convert(In :: binary(), Format :: png|jpeg|webp|gif) -\u003e {ok, Out :: binary()} |\n                                                              {error, Reason :: error_reason()}.\n```\n\nShorthand for `convert(In, Format, [])`.\n\n### convert/3\n```erl\n-spec convert(In :: binary(), Format :: png|jpeg|webp|gif,\n              Options :: [convert_opt() | limit_opt()]) -\u003e\n                   {ok, Out :: binary()} |\n                   {error, Reason :: error_reason()}.\n```\nThe function converts incoming data `In` into format `Format`. Note that you don't\nhave to pass the format of incoming data, because it will be detected automatically\nusing `get_type/1` function. In the case of an error you can use `Reason` to produce\na human-readable diagnostic text using `format_error/1`.\nThe function also accepts a proplist of `Options`. Currently available options are:\n- `{scale, {Width, Height}}`: scales image to the new `Width` and `Height`.\n  No scaling is applied by default.\n- `{rate_limit, N}`: limit the number of calls to `N` per minute, where\n  `N \u003e 0`. Must be used only in conjunction with `limit_by`.\n- `{limit_by, Term}`: apply `rate_limit` (see above) to the entity associtated\n  with `Term`. The `Term` may represent any value, such as an IP address, a username\n  and so on. The `Term` must not be atom `undefined`. For example a call to\n  `convert(Data, Format, [{limit_by, {192,168,0,1}}, {rate_limit, 10}])`\n  will fail with `{error, too_man_requests}` if called more than 10 times within a minute.\n\n**WARNING**: the maximum resolution of an incoming image is hardcoded to be 25Mpx.\nThis is a protection against decompression bombs.\n\n### identify/1\n```erl\n-spec identify(Img :: binary()) -\u003e {ok, Info :: info()} | {error, error_reason()}.\n```\nShorthand for `identify(Img, [])`.\n\n### identify/2\n```erl\n-spec identify(Img :: binary(), LimitOptions :: [limit_opt()]) -\u003e\n                    {ok, Info :: info()} | {error, error_reason()}.\n```\nThe function returns information about image `Img`, where `Info` is represented as:\n```erl\n[{type, Type :: img_type()},\n {width, Width :: non_neg_integer()},\n {height, Height :: non_neg_integer()}]\n```\nIt is safe to assume that `Info` always contains all these properties.\nYou can set limiting options in `LimitOptions`, that is `rate_limit` and `limit_by`.\nThe meaning of the limiting options is the same as in `convert/3`.\n\n**NOTE**: If you only need to get a type of an image, you're better off using\n`get_type/1` function, because it doesn't involve interaction with `eimp` process\nand is, thus, much faster.\n\n### format_error/1\n```erl\n-spec format_error(Reason :: error_reason()) -\u003e binary().\n```\nCreates diagnostic text from an error generated by `convert/2`.\nThe `Reason` can have the following values:\n```erl\n-type error_reason() :: unsupported_format |\n                        timeout |\n                        disconnected |\n                        encode_failure |\n                        decode_failure |\n\t\t\ttransform_failure |\n\t\t\ttoo_many_requests |\n\t\t\timage_too_big.\n```\n\n### get_type/1\n```erl\n-spec get_type(Data :: binary()) -\u003e png | jpeg | webp | gif | unknown.\n```\nDetects image format of `Data`.\n\n### is_supported/1\n```erl\n-spec is_supported(Format :: atom()) -\u003e boolean.\n```\nReturns `true` if `Format` is known and compiled and `false` otherwise.\n\n### supported_formats/0\n```erl\n-spec supported_formats() -\u003e [png | jpeg | webp | gif].\n```\nReturns a list of all known and compiled formats.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprocessone%2Feimp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprocessone%2Feimp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprocessone%2Feimp/lists"}