{"id":22157441,"url":"https://github.com/g0dkar/qrcode-kotlin","last_synced_at":"2025-04-12T15:34:18.001Z","repository":{"id":41951442,"uuid":"418322972","full_name":"g0dkar/qrcode-kotlin","owner":"g0dkar","description":"QRCode Generator implemented in pure Kotlin","archived":false,"fork":false,"pushed_at":"2025-04-10T21:59:11.000Z","size":5521,"stargazers_count":218,"open_issues_count":18,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-10T22:30:58.144Z","etag":null,"topics":["android","java","jvm","kotlin","qr-code","qrcode","qrcode-generator"],"latest_commit_sha":null,"homepage":"https://qrcodekotlin.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g0dkar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"zenodo":null},"funding":{"github":"g0dkar","ko_fi":"g0dkar"}},"created_at":"2021-10-18T02:55:48.000Z","updated_at":"2025-04-01T22:35:38.000Z","dependencies_parsed_at":"2023-10-28T14:31:37.978Z","dependency_job_id":"6fe8f0ee-f843-43ef-a8fc-be0a48794231","html_url":"https://github.com/g0dkar/qrcode-kotlin","commit_stats":{"total_commits":110,"total_committers":3,"mean_commits":"36.666666666666664","dds":0.4818181818181818,"last_synced_commit":"f5e3bd8dbd7b5eada8f267e5339ac2ccea3bc6b0"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0dkar%2Fqrcode-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0dkar%2Fqrcode-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0dkar%2Fqrcode-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g0dkar%2Fqrcode-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g0dkar","download_url":"https://codeload.github.com/g0dkar/qrcode-kotlin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248589933,"owners_count":21129708,"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":["android","java","jvm","kotlin","qr-code","qrcode","qrcode-generator"],"created_at":"2024-12-02T03:08:54.731Z","updated_at":"2025-04-12T15:34:17.984Z","avatar_url":"https://github.com/g0dkar.png","language":"JavaScript","funding_links":["https://github.com/sponsors/g0dkar","https://ko-fi.com/g0dkar","https://www.paypal.com/donate/?business=EFVC68BFJQWSC\u0026no_recurring=0\u0026item_name=Rafael+is+working+on+Open+Source+software+in+his+free+time.+This+helps+him+keep+this+up+for+longer%2C+and+with+higher+quality%21\u0026currency_code=BRL"],"categories":[],"sub_categories":[],"readme":"# QRCode-Kotlin\n\n[![License](https://img.shields.io/github/license/g0dkar/qrcode-kotlin)](LICENSE)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.g0dkar/qrcode-kotlin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.g0dkar%22%20AND%20a:%22qrcode-kotlin%22)\n\n💚 [_**Disponível em Português (Brasil)**_](README.pt-br.md) 💛\n\n![QRCode Kotlin Logo](examples/kotlin/project-banner.png)\n\nCreating QRCodes in Kotlin (and Java) is harder than it should be. **QRCode-Kotlin aims to bring a simple,\nstraightforward and customizable way to create QRCodes**, especially in the backend.\n\nIt is with this mission in mind that we keep doing our best to learn how developers use this library and their goals so\nthat we can provide a better library/API for them. Please, feel free to share if and how you're using this project ^^\n\n* **Pure Kotlin:** Rewritten on pure Kotlin from a reference implementation of the QRCode spec\n  by [Kazuhiko Arase](https://github.com/kazuhikoarase/qrcode-generator)\n* **Lightweight:** No dependencies, `~115KB` and it does what it says on the tin.\n* **Easy to use:** Quickly and easily implement QRCodes with few lines of code.\n* **Good-looking:** Many developers don't have time and sometimes knowledge to implement the perfect QRCode,\n  so this library tries to generate good-looking QRCodes by default.\n* **Server friendly:** The JVM version is mainly focused on a personal use-case where I needed to generate QRCodes on\n  the backend, but all libraries I found were either complex or huge, usually both.\n* **Multiplatform:** This is a KMP library with support to Java, JavaScript, Android, iOS and tvOS.\n\n## Table of Contents\n\n\u003c!-- TOC --\u003e\n\n* [Installation](#installation)\n* [Usage](#usage)\n    * [Spring Framework and/or Spring Boot](#spring-framework-andor-spring-boot)\n* [License](#license)\n* [Thanks and Acknowledgements](#thanks-and-acknowledgements)\n* [Support and Links](#support-and-links)\n\n\u003c!-- TOC --\u003e\n\n## 1. Installation\n\nThe library is available\nfrom [Maven Central](https://search.maven.org/artifact/io.github.g0dkar/qrcode-kotlin/4.4.1/qrcode-kotlin)\nand [NPM JS](https://www.npmjs.com/package/qrcode-kotlin), so you can add it to your project as a dependency like any\nother:\n\n**Gradle:**\n\n```groovy\n// Use this for both Android and JVM\nimplementation(\"io.github.g0dkar:qrcode-kotlin:4.4.1\")\n```\n\n**Maven - JVM:**\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.g0dkar\u003c/groupId\u003e\n    \u003cartifactId\u003eqrcode-kotlin-jvm\u003c/artifactId\u003e\n    \u003cversion\u003e4.4.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n**Maven - Android:**\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.g0dkar\u003c/groupId\u003e\n    \u003cartifactId\u003eqrcode-kotlin-android\u003c/artifactId\u003e\n    \u003cversion\u003e4.4.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n**NodeJS:**\n\n```shell\nnpm install qrcode-kotlin@4.4.1\n```\n\n**Browser:**\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/g0dkar/qrcode-kotlin@main/release/qrcode-kotlin.min.js\" type=\"application/javascript\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nTo create QRCodes, the main class that should be used is the `qrcode.render.QRCode` class. It has static methods to help\nyou create a QRCode the way you want:\n\n```kotlin\n// Use one of these:\n\nval squares = QRCode.ofSquares()\n\nval circles = QRCode.ofCircles()\n\nval roundedSquares = QRCode.ofRoundedSquares()\n```\n\nWith that, you'll have a [QRCodeBuilder](src/commonMain/kotlin/qrcode/QRCodeBuilder.kt) instance. It has methods to\nadjust colors, size, spacing, add a logo and more! Also, make sure to check\nthe [Colors](src/commonMain/kotlin/qrcode/color/Colors.kt) class as well.\n\nHere's a code to get you started:\n\n```kotlin\nval helloWorld = QRCode.ofSquares()\n    .withColor(Colors.DEEP_SKY_BLUE) // Default is Colors.BLACK\n    .withSize(10) // Default is 25\n    .build(\"Hello world!\")\n\n// By default, QRCodes are rendered as PNGs.\nval pngBytes = helloWorld.render()\n\nFileOutputStream(\"hello-world.png\").use { it.write(pngBytes) }\n```\n\nWe highly recommend that you check out some examples:\n\n* [All sorts of shapes](examples/kotlin/src/main/kotlin/Example01-Shapes.kt): Squares, Circles, Rounded Squares and\n  Custom shapes\n* [All about colors](examples/kotlin/src/main/kotlin/Example02-Colors.kt): Foreground, Background, Transparent\n  backgrounds, Linear Gradient colors\n* [Adding a Logo](examples/kotlin/src/main/kotlin/Example03-Logo.kt): Add a logo and remove the cells behind it, or\n  don't :)\n* [SVG QRCodes](examples/kotlin/src/main/kotlin/Example04-SVG.kt): How to extend the renderer to render SVG (uses [JFree SVG](https://github.com/jfree/jfreesvg))\n* [The banner on the top of this README](examples/kotlin/src/main/kotlin/ProjectLogo.kt): Yup, all done with the\n  library ^^\n\nThe examples show pretty much all that can be done with the library! Even how to extend it so that it can create SVG\nQRCodes ;)\n\nYou can mix and match all those together. Try generating the library logo and banner with gradients and all in SVG ;)\n\n### Spring Framework and/or Spring Boot\n\nAs said earlier, one of the main reasons I developed this library was to use it on a backend application. So it is only\nnatural to show how to do that :)\n\nThis Spring Framework/Boot controller method can generate QRCodes of a given content:\n\n```kotlin\nimport org.springframework.core.io.ByteArrayResource\nimport org.springframework.http.HttpHeaders.CONTENT_DISPOSITION\nimport org.springframework.http.MediaType.IMAGE_PNG_VALUE\n\n@GetMapping(\"/qrcode\")\nfun generateQrCode(content: String): ResponseEntity\u003cByteArrayResource\u003e {\n    val pngData = QRCode.ofSquares()\n        .build(content)\n        .render()\n    val resource = ByteArrayResource(pngData, IMAGE_PNG_VALUE)\n\n    return ResponseEntity.ok()\n        .header(CONTENT_DISPOSITION, \"attachment; filename=\\\"qrcode.png\\\"\")\n        .body(resource)\n}\n```\n\n## Changes from v3\n\nThe main changes coming from `v3.3.0` are:\n\n1. The main package of the classes was changed from `io.github.g0dkar.qrcode` to simply `qrcode`\n    * The old name doesn't help languages that don't have the \"package\" concept, and other Kotlin libraries already name\n      their main package this way.\n2. The old `QRCode` class was rewritten to be easier to create better looking QRCodes . The previous `QRCode` class was\n   renamed to [QRCodeProcessor](src/commonMain/kotlin/qrcode/raw/QRCodeProcessor.kt), with very minor API changes.\n    * **For most of the simple cases, the new `QRCode` class is compatible with the old one!**\n3. A bunch of optimizations on how the QRCode is drawn. Previously, we'd had a canvas for each square, which would then\n   be copied into the QRCode. This was changed to have just one large canvas where each square will be individually\n   drawn directly.\n4. iOS and tvOS Support: Starting from `v4.0.7` an initial implementation of the `QRCodeGraphics` so that iOS and tvOS\n   are now supported. **Any and all [feedback](https://github.com/g0dkar/qrcode-kotlin/issues/85) are very welcome!** -\n   Thanks a lot to [ruicanas](https://github.com/ruicanas) for all his contributions to this feature :D\n\n## License\n\nCopyright since 2021 Rafael M. Lins, Licensed under the [MIT License](https://rafaellins.mit-license.org/2021/).\n\nQR Code is trademarked by Denso Wave, Inc.\n\n## Thanks and Acknowledgements\n\n* [Kazuhiko Arase](https://github.com/kazuhikoarase): For his reference implementation!\n* [Paul Varry](https://github.com/pvarry): for opening the first few issues on the repo and helping to make the library\n  even better for everyone! :grin:\n* [Renan Lukas](https://github.com/RenanLukas): For his friendship, patience and help with Android, Gradle and a bunch\n  of other stuff during the development of v2.0.0 and v3.0.0!\n* [Doomsdayrs](https://github.com/Doomsdayrs): For pointing out how the library could be improved using Kotlin\n  Multiplatform, and helping out implementing it into the project.\n* An awesome, furry friend for all the support through all these years :)\n* [ruicanas](https://github.com/ruicanas): For not only pointing out some issues with the iOS implementation, but also\n  fixing them! Thank you so much ^^\n\n## Support and Links\n\n* If you found any bugs,\n  please [open an Issue](https://github.com/g0dkar/qrcode-kotlin/issues/new?assignees=g0dkar\u0026labels=bug\u0026template=bug_report.md\u0026title=)\n  😁\n* Have any suggestions? You\n  can [make them](https://github.com/g0dkar/qrcode-kotlin/issues/new?assignees=\u0026labels=\u0026template=feature_request.md\u0026title=)\n  as well!\n\nIf you enjoyed the library and want to get me some coffee, use the buttons below :love_you_gesture:\n\n[\u003cimg src=\"https://ko-fi.com/img/githubbutton_sm.svg\" alt=\"Buy me a coffee over at Ko-fi!\" width=\"200\"/\u003e](https://ko-fi.com/g0dkar)\n\n[\u003cimg src=\"https://raw.githubusercontent.com/andreostrovsky/donate-with-paypal/master/blue.svg\" alt=\"Buy me a coffee over at PayPal!\" width=\"200\"/\u003e](https://www.paypal.com/donate/?business=EFVC68BFJQWSC\u0026no_recurring=0\u0026item_name=Rafael+is+working+on+Open+Source+software+in+his+free+time.+This+helps+him+keep+this+up+for+longer%2C+and+with+higher+quality%21\u0026currency_code=BRL)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg0dkar%2Fqrcode-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg0dkar%2Fqrcode-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg0dkar%2Fqrcode-kotlin/lists"}