@@ -266,9 +266,60 @@ Kết quả:
266266
267267📸 ** Ảnh minh họa QR code tạo từ ví dụ:**
268268
269- ![ VietQR sample ] ( examples/vietqr_code.png )
269+ - QR code cơ bản (không icon):
270270
271- ### Example 4: Crawl danh sách ngân hàng từ API VietQR
271+ ![ VietQR sample] ( examples/vietqr_code.png )
272+
273+ ### Example 4: Tạo VietQR code với icon ở giữa
274+
275+ Xem file [ ` examples/qr_with_icon.py ` ] ( examples/qr_with_icon.py ) :
276+
277+ ``` python
278+ import base64
279+ from pathlib import Path
280+
281+ from vnqr import generate_vietqr_string, generate_qr_image_with_icon
282+
283+
284+ def main ():
285+ vietqr_string = generate_vietqr_string(
286+ bank_bin = " 970425" ,
287+ bank_account = " 123456789" ,
288+ total_amount = 100000 ,
289+ content = " Thanh toan don hang" ,
290+ )
291+
292+ icon_path = " vn_flag.png" # hoặc logo thương hiệu của bạn
293+
294+ qr_image_base64 = generate_qr_image_with_icon(
295+ qr_string = vietqr_string,
296+ icon_path = icon_path,
297+ icon_size_ratio = 0.15 ,
298+ )
299+
300+ with open (" vietqr_with_icon.png" , " wb" ) as f:
301+ f.write(base64.b64decode(qr_image_base64))
302+ ```
303+
304+ Chạy ví dụ:
305+
306+ ``` bash
307+ python examples/qr_with_icon.py
308+ ```
309+
310+ Kết quả:
311+
312+ - Tạo file ` vietqr_with_icon.png ` trong thư mục ` examples/ `
313+ - QR code có ** icon/logo ở giữa** , vẫn đảm bảo khả năng quét nhờ sử dụng error correction level cao
314+ - Script tự tạo một icon demo (` vn_flag.png ` ) nếu chưa có sẵn
315+
316+ 📸 ** Ảnh minh họa QR code tạo từ ví dụ:**
317+
318+ - QR code có icon ở giữa:
319+
320+ ![ VietQR sample with icon] ( examples/vietqr_with_icon.png )
321+
322+ ### Example 5: Crawl danh sách ngân hàng từ API VietQR
272323
273324Xem file [ ` examples/crawl_banks.py ` ] ( examples/crawl_banks.py ) :
274325
0 commit comments