Skip to content

Added support for SVG files in the AztecCode.save method#10

Merged
delimitry merged 1 commit intodelimitry:masterfrom
Zazzik1:zazzik1/support_for_svg
Sep 16, 2024
Merged

Added support for SVG files in the AztecCode.save method#10
delimitry merged 1 commit intodelimitry:masterfrom
Zazzik1:zazzik1/support_for_svg

Conversation

@Zazzik1
Copy link
Copy Markdown
Contributor

@Zazzik1 Zazzik1 commented Sep 16, 2024

I added a new class SVGFactory, which allows to create SVG images based on the 2d matrix. The method SVGFactory.save is called in the AztecCode.save method if the file name ends with .svg. All of the code was covered by tests. Please find the example code below. The advantage of SVG is that it scales well without any loss of quality.

Unfortunately, I didn't add the option to provide text above the image, because we would need to attach heavy font files to each image (or provide links to fonts which is also not always possible). Also, I'm not sure if it would be possible to easily wrap long texts

aztec_code

py.test --verbose

test_aztec_code_generator.py::Test::test_find_optimal_sequence PASSED                                                            [ 12%]
test_aztec_code_generator.py::Test::test_get_data_codewords PASSED                                                               [ 25%]
test_aztec_code_generator.py::Test::test_optimal_sequence_to_bits PASSED                                                         [ 37%]
test_aztec_code_generator.py::Test::test_reed_solomon PASSED                                                                     [ 50%]
test_aztec_code_generator.py::TestSvgFactory::test_create_svg PASSED                                                             [ 62%]
test_aztec_code_generator.py::TestSvgFactory::test_init PASSED                                                                   [ 75%]
test_aztec_code_generator.py::TestSvgFactory::test_save PASSED                                                                   [ 87%]
test_aztec_code_generator.py::TestAztecCode::test_save_should_support_svg PASSED                                                 [100%]

========================================================== 8 passed in 0.09s ==========================================================

@delimitry delimitry merged commit a247d98 into delimitry:master Sep 16, 2024
@Zazzik1
Copy link
Copy Markdown
Contributor Author

Zazzik1 commented Sep 16, 2024

Hi @dlenski, would you like to include this feature in your fork https://github.com/dlenski/aztec_code_generator and pypi? Should I open a new PR for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants