Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size cannot be set. #60

Open
Craftint opened this issue Dec 22, 2020 · 1 comment
Open

Size cannot be set. #60

Craftint opened this issue Dec 22, 2020 · 1 comment

Comments

@Craftint
Copy link

encoded_data = encode('A', size='10x10')
print(encoded_data.width)
print(encoded_data.height)

Returns

70
70

While I have set it to be 10x10.

@MathijsNL
Copy link

MathijsNL commented May 17, 2022

The width and height of the resulting image is 70x70 pixels.

The datamatrix itself is 10x10 cells.

The border around the encoded datamatrix is 10 pixels, so 20 in total. That leaves us with 50 pixels, 5 pixels per cell.

If you want to somehow modify this you can cut off the border and resize as needed.

from PIL import Image
import numpy as np
import cv2

img = Image.frombytes('RGB', (encoded_data.width, encoded_data.height), encoded_data.pixels)
img_cv2 = np.array(img)
resized = cv2.resize(img_cv2 , (14,14), interpolation = cv2.INTER_CUBIC)

resized = cv2.resize(img_cv2 , (14,14), interpolation = cv2.INTER_CUBIC)

Result:

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

No branches or pull requests

2 participants