fastqr 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/BUILD.md +482 -0
  3. data/CHANGELOG.md +51 -0
  4. data/CMakeLists.txt +126 -0
  5. data/CONTRIBUTING.md +63 -0
  6. data/DISTRIBUTION.md +730 -0
  7. data/INSTALL.md +171 -0
  8. data/LICENSE +39 -0
  9. data/PREBUILT.md +171 -0
  10. data/README.md +312 -0
  11. data/VERSION +1 -0
  12. data/bindings/nodejs/binding.gyp +38 -0
  13. data/bindings/nodejs/fastqr_node.cpp +125 -0
  14. data/bindings/nodejs/index.d.ts +80 -0
  15. data/bindings/nodejs/index.js +187 -0
  16. data/bindings/nodejs/lib/platform.js +72 -0
  17. data/bindings/nodejs/package.json +45 -0
  18. data/bindings/nodejs/test/test.js +45 -0
  19. data/bindings/php/fastqr_php.cpp +85 -0
  20. data/bindings/php/src/FastQR.php +316 -0
  21. data/bindings/php/tests/FastQRTest.php +97 -0
  22. data/bindings/ruby/extconf.rb +29 -0
  23. data/bindings/ruby/fastqr_ruby.cpp +122 -0
  24. data/bindings/ruby/lib/fastqr/platform.rb +70 -0
  25. data/bindings/ruby/lib/fastqr/version.rb +6 -0
  26. data/bindings/ruby/lib/fastqr.rb +129 -0
  27. data/bindings/ruby/prebuilt/macos-arm64.tar.gz +1 -0
  28. data/bindings/ruby/prebuilt/macos-x86_64.tar.gz +1 -0
  29. data/build.sh +109 -0
  30. data/cmake/fastqrConfig.cmake.in +6 -0
  31. data/composer.json +36 -0
  32. data/docs/CLI_USAGE.md +478 -0
  33. data/docs/NODEJS_USAGE.md +694 -0
  34. data/docs/PHP_USAGE.md +815 -0
  35. data/docs/README.md +191 -0
  36. data/docs/RUBY_USAGE.md +537 -0
  37. data/examples/CMakeLists.txt +7 -0
  38. data/examples/basic.cpp +58 -0
  39. data/include/fastqr.h +97 -0
  40. data/include/stb_image.h +7988 -0
  41. data/include/stb_image_write.h +1724 -0
  42. data/phpunit.xml +18 -0
  43. data/prebuilt/README.md +131 -0
  44. data/scripts/README.md +248 -0
  45. data/scripts/build-binaries.sh +98 -0
  46. data/scripts/build-local.sh +18 -0
  47. data/scripts/install.sh +87 -0
  48. data/scripts/release.sh +78 -0
  49. data/scripts/update-version.sh +58 -0
  50. data/src/cli.cpp +316 -0
  51. data/src/fastqr.cpp +665 -0
  52. data/test.sh +86 -0
  53. metadata +155 -0
data/docs/CLI_USAGE.md ADDED
@@ -0,0 +1,478 @@
1
+ # FastQR CLI Usage Guide
2
+
3
+ Complete guide for using the FastQR command-line tool.
4
+
5
+ ## Installation
6
+
7
+ ### macOS (Homebrew)
8
+ ```bash
9
+ brew tap tranhuucanh/fastqr
10
+ brew install fastqr
11
+ ```
12
+
13
+ ### Ubuntu/Debian
14
+ ```bash
15
+ wget https://github.com/tranhuucanh/fastqr/releases/download/v1.0.0/fastqr-1.0.0-linux-x64.deb
16
+ sudo dpkg -i fastqr-1.0.0-linux-x64.deb
17
+ ```
18
+
19
+ ### From Source
20
+ ```bash
21
+ git clone https://github.com/tranhuucanh/fastqr.git
22
+ cd fastqr
23
+ ./build.sh
24
+ cd build
25
+ sudo make install
26
+ ```
27
+
28
+ ## Basic Usage
29
+
30
+ ```bash
31
+ fastqr <data> <output_file>
32
+ ```
33
+
34
+ **Example:**
35
+ ```bash
36
+ fastqr "Hello World" qr.png
37
+ ```
38
+
39
+ ## Command-Line Options
40
+
41
+ ### Help and Version
42
+
43
+ ```bash
44
+ # Show help
45
+ fastqr --help
46
+ fastqr -h
47
+
48
+ # Show version
49
+ fastqr --version
50
+ fastqr -v
51
+ ```
52
+
53
+ ### Size (`-s`, `--size`)
54
+
55
+ Specify output size in pixels. QR codes are always square.
56
+
57
+ **Format:** `SIZE`
58
+
59
+ ```bash
60
+ # 500x500 pixels
61
+ fastqr -s 500 "Large QR" large.png
62
+
63
+ # 1000x1000 pixels
64
+ fastqr -s 1000 "Very Large" xl.png
65
+
66
+ # 2000x2000 pixels (exact size!)
67
+ fastqr -s 2000 "Huge QR" huge.png
68
+ ```
69
+
70
+ **Default:** `300` (300x300 pixels)
71
+
72
+ ### Optimize (`-o`, `--optimize`)
73
+
74
+ Auto round-up size to nearest integer multiple of QR code module size for best performance.
75
+
76
+ ```bash
77
+ # Optimized size (fastest generation)
78
+ fastqr -s 500 -o "Fast QR" fast.png
79
+
80
+ # Best for batch processing
81
+ fastqr -F batch.txt output_dir/ -s 500 -o
82
+ ```
83
+
84
+ **Note:** With `-o`, the actual output size may be slightly larger than requested (e.g., 500 → 493 or 506) to match QR code module alignment, resulting in sharper pixels and faster generation.
85
+
86
+ ### Foreground Color (`-f`, `--foreground`)
87
+
88
+ Set QR code color using RGB values (0-255).
89
+
90
+ **Format:** `R,G,B`
91
+
92
+ ```bash
93
+ # Red QR code
94
+ fastqr -f 255,0,0 "Red" red.png
95
+
96
+ # Blue QR code
97
+ fastqr -f 0,0,255 "Blue" blue.png
98
+
99
+ # Green QR code
100
+ fastqr -f 0,255,0 "Green" green.png
101
+
102
+ # Custom color (orange)
103
+ fastqr -f 255,165,0 "Orange" orange.png
104
+
105
+ # Dark gray
106
+ fastqr -f 50,50,50 "Dark Gray" gray.png
107
+ ```
108
+
109
+ **Default:** `0,0,0` (black)
110
+
111
+ ### Background Color (`-b`, `--background`)
112
+
113
+ Set background color using RGB values (0-255).
114
+
115
+ **Format:** `R,G,B`
116
+
117
+ ```bash
118
+ # White background (default)
119
+ fastqr -b 255,255,255 "White BG" white_bg.png
120
+
121
+ # Light yellow background
122
+ fastqr -b 255,255,200 "Yellow BG" yellow_bg.png
123
+
124
+ # Light blue background
125
+ fastqr -b 200,220,255 "Blue BG" blue_bg.png
126
+
127
+ # Transparent-looking (very light gray)
128
+ fastqr -b 245,245,245 "Light Gray BG" light_bg.png
129
+ ```
130
+
131
+ **Default:** `255,255,255` (white)
132
+
133
+ ### Combine Colors
134
+
135
+ ```bash
136
+ # Red QR on yellow background
137
+ fastqr -f 255,0,0 -b 255,255,200 "Red on Yellow" red_yellow.png
138
+
139
+ # Blue QR on light blue background
140
+ fastqr -f 0,0,200 -b 200,220,255 "Blue Theme" blue_theme.png
141
+
142
+ # White QR on black background (inverted)
143
+ fastqr -f 255,255,255 -b 0,0,0 "Inverted" inverted.png
144
+ ```
145
+
146
+ ### Error Correction Level (`-e`, `--error-level`)
147
+
148
+ Set error correction capability. Higher levels allow QR code to be readable even when partially damaged or obscured.
149
+
150
+ **Values:** `L`, `M`, `Q`, `H`
151
+
152
+ ```bash
153
+ # Low (~7% recovery)
154
+ fastqr -e L "Low EC" low_ec.png
155
+
156
+ # Medium (~15% recovery) - DEFAULT
157
+ fastqr -e M "Medium EC" medium_ec.png
158
+
159
+ # Quartile (~25% recovery)
160
+ fastqr -e Q "Quartile EC" quartile_ec.png
161
+
162
+ # High (~30% recovery) - Best for logos
163
+ fastqr -e H "High EC" high_ec.png
164
+ ```
165
+
166
+ **Default:** `M` (Medium)
167
+
168
+ **When to use:**
169
+ - `L`: Simple QR codes, maximum data capacity
170
+ - `M`: General purpose (default)
171
+ - `Q`: QR codes with small logos
172
+ - `H`: QR codes with large logos or harsh environments
173
+
174
+ ### Logo (`-l`, `--logo`)
175
+
176
+ Embed a logo image in the center of the QR code.
177
+
178
+ ```bash
179
+ # Add logo with default size (20%)
180
+ fastqr -l logo.png "Company" with_logo.png
181
+
182
+ # Logo with specific size (25%)
183
+ fastqr -l logo.png -p 25 "Company" logo_25.png
184
+
185
+ # Logo with high error correction (recommended)
186
+ fastqr -e H -l logo.png "Company" logo_high_ec.png
187
+
188
+ # Full example with logo
189
+ fastqr -s 800x800 \
190
+ -e H \
191
+ -l company_logo.png \
192
+ -p 30 \
193
+ "https://company.com" \
194
+ company_qr.png
195
+ ```
196
+
197
+ ### Logo Size (`-p`, `--logo-size`)
198
+
199
+ Specify logo size as percentage of QR code size.
200
+
201
+ **Range:** `1-50` (percentage)
202
+
203
+ ```bash
204
+ # Small logo (15%)
205
+ fastqr -l logo.png -p 15 "Small Logo" small_logo.png
206
+
207
+ # Medium logo (25%)
208
+ fastqr -l logo.png -p 25 "Medium Logo" medium_logo.png
209
+
210
+ # Large logo (35%)
211
+ fastqr -l logo.png -p 35 "Large Logo" large_logo.png
212
+ ```
213
+
214
+ **Default:** `20` (20%)
215
+
216
+ **Recommendation:** Use 20-30% for best results. Higher percentages require higher error correction (`-e H`).
217
+
218
+ ### Quality (`-q`, `--quality`)
219
+
220
+ Set image quality for lossy formats (JPG, WebP).
221
+
222
+ **Range:** `1-100`
223
+
224
+ ```bash
225
+ # Maximum quality
226
+ fastqr -q 100 "Max Quality" max.png
227
+
228
+ # High quality (default)
229
+ fastqr -q 95 "High Quality" high.png
230
+
231
+ # Medium quality (smaller file)
232
+ fastqr -q 75 "Medium Quality" medium.png
233
+
234
+ # Low quality (very small file)
235
+ fastqr -q 50 "Low Quality" low.png
236
+
237
+ # For JPG
238
+ fastqr -q 90 "JPG Quality" output.jpg
239
+ ```
240
+
241
+ **Default:** `95`
242
+
243
+ **Note:** For PNG (lossless), quality setting has minimal effect.
244
+
245
+ ### Batch Mode (`-F`, `--file`)
246
+
247
+ Process multiple QR codes at once - **7x faster** than calling fastqr multiple times!
248
+
249
+ ```bash
250
+ # Create batch input file (one QR text per line)
251
+ cat > batch.txt << EOF
252
+ QR Code 1
253
+ QR Code 2
254
+ QR Code 3
255
+ EOF
256
+
257
+ # Generate batch
258
+ fastqr -F batch.txt output_dir/
259
+
260
+ # With options (applied to all QR codes)
261
+ fastqr -F batch.txt output_dir/ -s 500 -o
262
+
263
+ # With colors and logo
264
+ fastqr -F batch.txt output_dir/ \
265
+ -s 600 \
266
+ -f 255,0,0 \
267
+ -e H \
268
+ -l logo.png
269
+ ```
270
+
271
+ **Output:** Creates numbered files: `output_dir/1.png`, `output_dir/2.png`, `output_dir/3.png`, ...
272
+
273
+ **Performance:**
274
+ - 100 QR codes: ~0.05s (vs ~0.3s with 100 calls)
275
+ - 1000 QR codes: ~0.4s (vs ~3s with 1000 calls)
276
+
277
+ ## Output Formats
278
+
279
+ FastQR automatically detects format from file extension:
280
+
281
+ ```bash
282
+ # PNG (default, lossless)
283
+ fastqr "Data" output.png
284
+
285
+ # JPEG (lossy, smaller file)
286
+ fastqr -q 90 "Data" output.jpg
287
+
288
+ # WebP (modern, smaller file)
289
+ fastqr -q 85 "Data" output.webp
290
+ ```
291
+
292
+ ## UTF-8 Support
293
+
294
+ FastQR fully supports UTF-8 characters including emojis!
295
+
296
+ ```bash
297
+ # Vietnamese
298
+ fastqr "Xin chào Việt Nam! 🇻🇳" vietnamese.png
299
+
300
+ # Japanese (Hiragana)
301
+ fastqr "こんにちは" japanese_hiragana.png
302
+
303
+ # Japanese (Kanji)
304
+ fastqr "日本語" japanese_kanji.png
305
+
306
+ # Chinese
307
+ fastqr "你好世界" chinese.png
308
+
309
+ # Emojis
310
+ fastqr "Hello 👋 World 🌍" emoji.png
311
+
312
+ # Mixed
313
+ fastqr "Hello world - こんにちは - 你好 - Xin chào" mixed.png
314
+ ```
315
+
316
+ ## Complete Examples
317
+
318
+ ### 1. Simple QR Code
319
+ ```bash
320
+ fastqr "https://example.com" simple.png
321
+ ```
322
+
323
+ ### 2. Large QR Code
324
+ ```bash
325
+ fastqr -s 1000 "https://example.com" large.png
326
+ ```
327
+
328
+ ### 3. Colored QR Code
329
+ ```bash
330
+ fastqr -s 500 \
331
+ -f 0,100,200 \
332
+ -b 240,248,255 \
333
+ "Colored QR Code" \
334
+ colored.png
335
+ ```
336
+
337
+ ### 4. QR Code with Logo
338
+ ```bash
339
+ fastqr -s 800 \
340
+ -e H \
341
+ -l company_logo.png \
342
+ -p 25 \
343
+ "https://company.com" \
344
+ company_qr.png
345
+ ```
346
+
347
+ ### 5. Business Card QR
348
+ ```bash
349
+ fastqr -s 600 \
350
+ -f 0,0,0 \
351
+ -b 255,255,255 \
352
+ -e H \
353
+ "BEGIN:VCARD
354
+ VERSION:3.0
355
+ FN:John Doe
356
+ ORG:Company Inc
357
+ TEL:+1234567890
358
+ EMAIL:john@company.com
359
+ URL:https://company.com
360
+ END:VCARD" \
361
+ vcard.png
362
+ ```
363
+
364
+ ### 6. WiFi QR Code
365
+ ```bash
366
+ fastqr -s 500 \
367
+ -e H \
368
+ "WIFI:T:WPA;S:NetworkName;P:password123;;" \
369
+ wifi.png
370
+ ```
371
+
372
+ ### 7. Vietnamese Event
373
+ ```bash
374
+ fastqr -s 700 \
375
+ -f 255,0,0 \
376
+ -b 255,255,200 \
377
+ "Sự kiện: Hội thảo công nghệ
378
+ Thời gian: 20/10/2025
379
+ Địa điểm: TP.HCM" \
380
+ event.png
381
+ ```
382
+
383
+ ### 8. Maximum Quality Logo QR
384
+ ```bash
385
+ fastqr -s 2000 \
386
+ -e H \
387
+ -l logo_hires.png \
388
+ -p 30 \
389
+ -q 100 \
390
+ "https://premium.com" \
391
+ premium.png
392
+ ```
393
+
394
+ ### 9. Batch Generation (7x faster!)
395
+ ```bash
396
+ # Create batch file
397
+ cat > products.txt << EOF
398
+ Product 001
399
+ Product 002
400
+ Product 003
401
+ EOF
402
+
403
+ # Generate 1000 QR codes in ~0.4s
404
+ fastqr -F products.txt qr_codes/ -s 500 -o
405
+ ```
406
+
407
+ ## Tips and Best Practices
408
+
409
+ ### Size Selection
410
+ - **Small (300-500px)**: Screen display, web pages
411
+ - **Medium (500-1000px)**: Print materials, posters
412
+ - **Large (1000-2000px)**: Banners, billboards
413
+ - **Very Large (2000+px)**: High-resolution prints
414
+
415
+ ### Error Correction
416
+ - Use `H` level when adding logos
417
+ - Use `H` level for outdoor/damaged environments
418
+ - Use `L` or `M` for simple QR codes (more data capacity)
419
+
420
+ ### Colors
421
+ - Ensure high contrast (dark QR on light background)
422
+ - Avoid very light QR codes (may not scan well)
423
+ - Test scannability after changing colors
424
+
425
+ ### Logos
426
+ - Use square logos for best results
427
+ - Keep logo size 20-30% for reliable scanning
428
+ - Use transparent background PNGs
429
+ - Always use high error correction (`-e H`)
430
+
431
+ ### File Formats
432
+ - Use PNG for lossless quality
433
+ - Use JPG for smaller file sizes (web)
434
+ - Use WebP for modern browsers (best compression)
435
+
436
+ ## Troubleshooting
437
+
438
+ ### QR Code Won't Scan
439
+ 1. Increase error correction: `-e H`
440
+ 2. Reduce logo size: `-p 20` or remove logo
441
+ 3. Increase contrast (darker QR, lighter background)
442
+ 4. Increase size: `-s 800`
443
+ 5. Use optimize flag for sharper pixels: `-o`
444
+
445
+ ### File Size Too Large
446
+ 1. Use JPG format: `output.jpg`
447
+ 2. Reduce quality: `-q 75`
448
+ 3. Use WebP format: `output.webp`
449
+
450
+ ### Colors Not Showing
451
+ 1. Check RGB values are correct (0-255)
452
+ 2. Ensure high contrast between foreground and background
453
+
454
+ ### Logo Not Visible
455
+ 1. Increase logo size: `-p 30`
456
+ 2. Use high error correction: `-e H`
457
+ 3. Check logo file exists and is readable
458
+
459
+ ## Getting Help
460
+
461
+ ```bash
462
+ # Show all options
463
+ fastqr --help
464
+
465
+ # Show version
466
+ fastqr --version
467
+
468
+ # Report issues
469
+ https://github.com/tranhuucanh/fastqr/issues
470
+ ```
471
+
472
+ ## See Also
473
+
474
+ - [README.md](../README.md) - Overview and installation
475
+ - [Ruby Usage](RUBY_USAGE.md) - Ruby/Rails guide
476
+ - [Node.js Usage](NODEJS_USAGE.md) - Node.js guide
477
+ - [PHP Usage](PHP_USAGE.md) - PHP guide
478
+