{"id":13611219,"url":"https://github.com/rxing-core/rxing-wasm","last_synced_at":"2025-04-13T01:35:06.725Z","repository":{"id":65281358,"uuid":"588756306","full_name":"rxing-core/rxing-wasm","owner":"rxing-core","description":"WASM bindings for common rxing functions","archived":false,"fork":false,"pushed_at":"2024-03-24T14:08:42.000Z","size":142,"stargazers_count":21,"open_issues_count":4,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-25T18:20:55.214Z","etag":null,"topics":["aztec","barcode","barcode-reader","barcode-scanner","coda","code128","code39","code98","datamatrix","javascript","maxicode","pdf417","qrcode","rust","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/rxing-wasm","language":"Rust","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/rxing-core.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}},"created_at":"2023-01-13T23:09:18.000Z","updated_at":"2024-07-24T22:58:06.253Z","dependencies_parsed_at":"2024-01-16T01:24:06.298Z","dependency_job_id":"9e8f83e4-3e28-4e47-86c4-7b55388e41c1","html_url":"https://github.com/rxing-core/rxing-wasm","commit_stats":{"total_commits":75,"total_committers":3,"mean_commits":25.0,"dds":"0.026666666666666616","last_synced_commit":"09d4cb9ac2c8addef7b26ca3d35e21906152c83c"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxing-core%2Frxing-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxing-core%2Frxing-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxing-core%2Frxing-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rxing-core%2Frxing-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rxing-core","download_url":"https://codeload.github.com/rxing-core/rxing-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654030,"owners_count":21140236,"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":["aztec","barcode","barcode-reader","barcode-scanner","coda","code128","code39","code98","datamatrix","javascript","maxicode","pdf417","qrcode","rust","wasm","webassembly"],"created_at":"2024-08-01T19:01:52.967Z","updated_at":"2025-04-13T01:35:06.447Z","avatar_url":"https://github.com/rxing-core.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# rxing-wasm\nWASM bindings for common rxing functions. The NPM link is [https://www.npmjs.com/package/rxing-wasm](https://www.npmjs.com/package/rxing-wasm) and the rust source is [https://github.com/rxing-core/rxing-wasm](https://github.com/hschimke/rxing-wasm).\n\n## Decode Multi Breaking Change with v0.3.0\nVersion `0.3.0` now returns `BarcodeResult` objects in a native javascript array. This fully deprecates the old method\nwhich returned a custom object with internal state.\n\n## Data\nThe `convert_js_image_to_luma` function is used to convert canvas image data to the luma 8\nformat that rxing expects. An example might look like to below.\n\n```javascript\nfunction decodeBarcode(canvas) {\n    let context = canvas.getContext('2d');\n    let height = canvas.height;\n    let width = canvas.width;\n    let imageData = context.getImageData(0, 0, width, height);\n\n    let data = imageData.data;\n    let luma8Data = convert_js_image_to_luma(data);\n    let parsedBarcode = decode_barcode(luma8Data, width, height);\n    \n    return parsedBarcode;\n}\n```\n\nThe `convert_canvas_to_luma` function is used to convert a canvas to the luma 8\nformat that rxing expects. An example might look like to below.\n\n```javascript\nfunction decodeBarcode(canvas) {\n    let height = canvas.height;\n    let width = canvas.width;\n    let luma8Data = convert_canvas_to_luma(canvas);\n    let parsedBarcode = decode_barcode(luma8Data, width, height);\n    \n    return parsedBarcode;\n}\n```\n\nThe `convert_imagedata_to_luma` function is used to convert an ImageData object to the luma 8\nformat that rxing expects. An example might look like to below.\n\n```javascript\nfunction decodeBarcode(canvas) {\n    let context = canvas.getContext('2d');\n    let height = canvas.height;\n    let width = canvas.width;\n    let imageData = context.getImageData(0, 0, width, height);\n\n    let luma8Data = convert_imagedata_to_luma(imageData);\n    let parsedBarcode = decode_barcode(luma8Data, width, height);\n    \n    return parsedBarcode;\n}\n```\n\n## Hints\n### Using the `DecodeHintDictionary` class\nAdd a hint with `set_hint(hint: DecodeHintTypes, value: string)`. The function returns `true` if the hint was added and `false` if it was not. The value of hint must be a `number` representing on of the enum values for `DecodeHintTypes`. The easiest way to use this is to simply pass in one of the values from `DecodeHintTypes`.\n\nRemove a hint using `remove_hint(hint: DecodeHintTypes)`. The function returns `true` if the hint was present and removed, and `false` otherwise. The hint value is the same as in the add_hint function.\n\n### `DecodeHintTypes` Values\nThe following values are available for the `DecodeHintTypes` enum.\n* `Other`: Unspecified, application-specific hint. This can be any string, only some decoders care about this value.\n* `PureBarcode`: Image is a pure monochrome image of a barcode. Should be a string with either \"true\" or \"false\".\n* `PossibleFormats`: A comma separated list (no spaces between elements), with the names of barcode formats to search for. For example, looking for a QrCode and a Datamatrix, one would pass in the string \"qrcode,datamatrix\".\n* `TryHarder`: Spend more time to try to find a barcode; optimize for accuracy, not speed. String with either \"true\" or \"false\".\n* `CharacterSet`: Specifies what character encoding to use when decoding, where applicable. This should be a string mapping to a character encoding.\n* `AllowedLengths`: Allowed lengths of encoded data -- reject anything else. A comma separated list of integers.\n* `AssumeCode39CheckDigit`: Assume Code 39 codes employ a check digit. A string with either \"true\" or \"false\".\n* `AssumeGs1`: Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed. For example this affects FNC1 handling for Code 128 (aka GS1-128). A string with either \"true\" or \"false\".\n* `ReturnCodabarStartEnd`: If true, return the start and end digits in a Codabar barcode instead of stripping them. They are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them to not be. A string with either \"true\" or \"false\".\n* `NeedResultPointCallback`: The caller needs to be notified via callback when a possible ResultPoint is found. Currently unsupported. In future will map to a (x: number, y: number) = {} function.\n* `AllowedEanExtensions`: Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this. A comma separated list of the allowed extension lengths, for example \"2\", \"5\" or \"2,5\". If it is optional to have an extension, do not set this hint. If this is set, and a UPC or EAN barcode is found but an extension is not, then no result will be returned at all.\n* `AlsoInverted`: If true, also tries to decode as inverted image. All configured decoders are simply called a second time with an inverted image. A string with either \"true\" or \"false\".\n\n## Result Metadata\nResult metadata is now available through the `get_result_metadata_name` method of the `BarcodeResult` class. The returned result is a javascript `Map` object representing availble decoded metadata. The possible keys are:\n* `OTHER`\n* `Orientation`\n* `Byte_Segments`\n* `Error_Correction_Level`\n* `Issue_Number`\n* `Suggested_Price`\n* `Possible_Country`\n* `UPC/EAN_Extension`\n* `PDF417_Extra_MetaData`\n* `Structured_Append_Sequence`\n* `Structured_Append_Parity`\n* `Symbology_Identifier`\n* `Is_Mirrored`\n* `Content_Type`\n\n\nIt is important to note that not all values will be set for all results.\n\n## Functions\n```rust\npub fn convert_js_image_to_luma(data: \u0026[u8]) -\u003e Vec\u003cu8\u003e;\n```\n\n```rust\npub fn encode_barcode(\n    data: \u0026str,\n    width: u32,\n    height: u32,\n    bc_type: BarcodeFormat,\n) -\u003e Result\u003cString, String\u003e;\n```\n\n```rust\npub fn decode_barcode(\n    data: Vec\u003cu8\u003e,\n    width: u32,\n    height: u32,\n    try_harder: Option\u003cbool\u003e,\n) -\u003e Result\u003cBarcodeResult, String\u003e;\n```\n\n```rust\npub fn decode_barcode_with_hints(\n    data: Vec\u003cu8\u003e,\n    width: u32,\n    height: u32,\n    hints: \u0026mut decode_hints::DecodeHintDictionary,\n) -\u003e Result\u003cBarcodeResult, String\u003e;\n```\n\n```rust\npub fn decode_multi(\n    data: Vec\u003cu8\u003e,\n    width: u32,\n    height: u32,\n    hints: \u0026mut decode_hints::DecodeHintDictionary,\n    filter_image: Option\u003cbool\u003e,\n) -\u003e Result\u003cVec\u003cBarcodeResult\u003e, String\u003e;\n```\n\n```rust\npub fn encode_barcode_with_hints(\n    data: \u0026str,\n    width: u32,\n    height: u32,\n    bc_type: BarcodeFormat,\n    hints: \u0026mut EncodeHintDictionary,\n) -\u003e Result\u003cString, String\u003e;\n```\n\n## Beta Features\n`encode_barcode_with_hints` is currently in alpha. The output and behaviour is unexpected and poorly documented. Use at your own risk, feature may change, unstable interface.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxing-core%2Frxing-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frxing-core%2Frxing-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frxing-core%2Frxing-wasm/lists"}