MCPcopy Create free account
hub / github.com/BadCafeCode/masquerade-nodes-comfyui / create_qr_code

Method create_qr_code

MaskNodes.py:1157–1180  ·  view source on GitHub ↗
(self, text, size, qr_version, error_correction, box_size, border)

Source from the content-addressed store, hash-verified

1155 CATEGORY = "Masquerade Nodes"
1156
1157 def create_qr_code(self, text, size, qr_version, error_correction, box_size, border):
1158 ensure_package("qrcode")
1159 import qrcode
1160 if error_correction =="L":
1161 error_level = qrcode.constants.ERROR_CORRECT_L
1162 elif error_correction =="M":
1163 error_level = qrcode.constants.ERROR_CORRECT_M
1164 elif error_correction =="Q":
1165 error_level = qrcode.constants.ERROR_CORRECT_Q
1166 else:
1167 error_level = qrcode.constants.ERROR_CORRECT_H
1168
1169 qr = qrcode.QRCode(
1170 version=qr_version,
1171 error_correction=error_level,
1172 box_size=box_size,
1173 border=border)
1174 qr.add_data(text)
1175 qr.make(fit=True)
1176 img = qr.make_image(fill_color="black", back_color="white")
1177 img = img.resize((size,size))
1178 # Convert img (a PIL Image) into a torch tensor
1179 tensor = torch.from_numpy(np.array(img))
1180 return (tensor2rgb(tensor.unsqueeze(0)),)
1181
1182def rgb2hsv(rgb):
1183 # rgb is a tensor in the form [B, H, W, C]

Callers

nothing calls this directly

Calls 2

ensure_packageFunction · 0.85
tensor2rgbFunction · 0.85

Tested by

no test coverage detected