{"id":22901762,"url":"https://github.com/mbuczko/clj-skalar","last_synced_at":"2025-12-12T01:17:37.129Z","repository":{"id":62432339,"uuid":"156622857","full_name":"mbuczko/clj-skalar","owner":"mbuczko","description":"Image processing based on pooled GM sessions","archived":false,"fork":false,"pushed_at":"2019-12-01T23:25:19.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-03T13:56:06.952Z","etag":null,"topics":["clojure","gm","image-processing"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbuczko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-07T23:38:37.000Z","updated_at":"2023-10-25T13:05:56.000Z","dependencies_parsed_at":"2022-11-01T20:46:47.253Z","dependency_job_id":null,"html_url":"https://github.com/mbuczko/clj-skalar","commit_stats":null,"previous_names":["mbuczko/skalar"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mbuczko/clj-skalar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbuczko%2Fclj-skalar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbuczko%2Fclj-skalar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbuczko%2Fclj-skalar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbuczko%2Fclj-skalar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbuczko","download_url":"https://codeload.github.com/mbuczko/clj-skalar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbuczko%2Fclj-skalar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273702382,"owners_count":25152882,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["clojure","gm","image-processing"],"created_at":"2024-12-14T01:40:48.716Z","updated_at":"2025-12-12T01:17:37.066Z","avatar_url":"https://github.com/mbuczko.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Clojars Project](https://img.shields.io/clojars/v/defunkt/skalar.svg)](https://clojars.org/defunkt/skalar)\n\n# What is Skalar\n\nSkalar is a humble attempt to build a fast [GraphicsMagick](http://www.graphicsmagick.org/) based image tranformation library.\nThere are already plenty of this kind of libraries all over the world and each one is special (at least in their authors' minds ;)\n\nSo, why _Skalar_?\n\nSkalar achieves its robustness via underlaying pool of opened connections to GM sessions. Instead of creating new session with _gm_ executable\neach time a request comes in, Skalar redirects request to first least-busy GM session (or more technically - the session with smallest number of assigned requests).\nOnce the number of assigned request on each opened sessions exceeds given capacity, Skalar adds one more session trying to balance incoming requests.\n\n# Usage\n\n```clojure\n(require '[clojure.java.io :as io])\n(require '[skalar.core :as sk])\n(require '[skalar.gm :as gm])\n\n(def input-file (io/file \"photo.jpg\"))\n\n(sk/convert input-file \n            :output \"photo.png\"\n            :processing [(gm/crop 10 10 100 100)\n                         (gm/resize \"200x200\" :exact :no-profiles)\n                         (gm/options {:auto-orient true})])\n```\n\nwhere `:processing` is a vector of [convert options](http://www.graphicsmagick.org/convert.html#conv-opti). Two of them (`-crop` and `-resize`) got a little helpers in\n`skalar.gm` namespace to save people from remembering crazy GM syntax. All other options can be provided via `skalar.gm/options` function in keywordized form (without\nprefixing -), so for example `{:auto-orient true}` gets translated to `-auto-orient`.\n\n# Custom pool\n\nSo far default GraphicsMagick pool of processes (sessions) was used, but sometimes it's better to create a customized one. Each pool is defined by 4 parameters:\n\n* base  : is a number of minimum sessions that need to be kept opened and ready for incoming requests.\n* capacity : is a number of requests each session can handle. Once the number of session exceeds _capacity_ a new session is being added. \n* max : maximum number of sessions that can be created.\n\nDefault pool is defined with `base=3`, `capacity=6`, `max=8`, and that simply translates to:\n\n_keep 3 opened sessions by default, consequently add new ones if number of requests for each existing session exceeds 6, but do not create more than 8 sessions in total_\n\nEach additionally created session will be immediately closed and removed from pool when number of request drops down to 0 at some point in time.\n\nLet's leave theory behind and create a custom pool:\n\n``` clojure\n(require '[skalar.pool :as sp])\n\n(def my-pool\n  (sp/create-pool 2 3 4))\n```\n\nand provide it via `:pool` option:\n\n``` clojure\n(sk/convert (sk/file-from-url \"https://images-assets.nasa.gov/image/PIA20912/PIA20912~orig.jpg\")\n            :output \"kręcioł.png\"\n            :processing [(gm/resize \"200x200\")]\n            :pool my-pool)\n```\n\n# Requirements\n\nAs mentioned Skalar bases on _gm_ executable which must be already installed to get this library running correctly.\nTo install _gm_ on Mac, simply use _brew_:\n\n``` shell\nbrew install gm\n```\n\nGraphicsMagick is also available on [Alpine Linux](https://alpinelinux.org/), so [docker](https://www.docker.com/) is your friend if you don't want to pollute your OS.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbuczko%2Fclj-skalar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbuczko%2Fclj-skalar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbuczko%2Fclj-skalar/lists"}