Search K
Are you an LLM? You can read better optimized documentation at /th/tools/image/barcode-read.md for this page in Markdown format
Barcode Reader
สแกนรูปภาพที่อัปโหลดหาบาร์โค้ดและ QR code ทุกประเภท ส่งคืนข้อความที่ถอดรหัส, ประเภทบาร์โค้ด และข้อมูลตำแหน่งของแต่ละโค้ดที่ตรวจพบ นอกจากนี้ยังสร้างรูปภาพที่มีคำอธิบายกำกับพร้อมกล่องขอบเขตสีรอบ ๆ โค้ดที่ตรวจพบ
API Endpoint
POST /api/v1/tools/image/barcode-read
รับข้อมูลแบบ multipart form data พร้อมไฟล์รูปภาพและฟิลด์ JSON settings ที่เป็นทางเลือก
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| tryHarder | boolean | No | true | เปิดใช้โหมดสแกนแบบเข้มข้นสำหรับบาร์โค้ดที่อ่านยากกว่า (ช้ากว่าแต่ละเอียดกว่า) |
Example Request
bash
curl -X POST http://localhost:1349/api/v1/tools/image/barcode-read \
-H "Authorization: Bearer si_your-api-key" \
-F "[email protected]" \
-F 'settings={"tryHarder": true}'Example Response
json
{
"filename": "receipt.jpg",
"barcodes": [
{
"type": "QRCode",
"text": "https://example.com/product/123",
"position": {
"topLeft": { "x": 100, "y": 50 },
"topRight": { "x": 250, "y": 50 },
"bottomLeft": { "x": 100, "y": 200 },
"bottomRight": { "x": 250, "y": 200 }
}
},
{
"type": "EAN-13",
"text": "5901234123457",
"position": {
"topLeft": { "x": 50, "y": 400 },
"topRight": { "x": 300, "y": 400 },
"bottomLeft": { "x": 50, "y": 450 },
"bottomRight": { "x": 300, "y": 450 }
}
}
],
"annotatedUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/annotated-receipt.png",
"previewUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/annotated-receipt.png"
}Response Fields
| Field | Type | Description |
|---|---|---|
| filename | string | ชื่อไฟล์ต้นฉบับ |
| barcodes | array | อาร์เรย์ของอ็อบเจกต์บาร์โค้ดที่ตรวจพบ |
| annotatedUrl | string or null | URL สำหรับดาวน์โหลดรูปภาพที่มีคำอธิบายกำกับ (null หากไม่พบบาร์โค้ด) |
| previewUrl | string or null | เหมือนกับ annotatedUrl (เพื่อความเข้ากันได้กับการแสดงตัวอย่างในฟรอนต์เอนด์) |
Barcode Object
| Field | Type | Description |
|---|---|---|
| type | string | รูปแบบบาร์โค้ด (QRCode, EAN-13, Code128, DataMatrix, PDF417 ฯลฯ) |
| text | string | เนื้อหาที่ถอดรหัสของบาร์โค้ด |
| position | object | กล่องขอบเขตพร้อมพิกัด topLeft, topRight, bottomLeft, bottomRight |
Supported Barcode Types
บาร์โค้ด 1 มิติ: Code128, Code39, Code93, Codabar, EAN-8, EAN-13, ITF, UPC-A, UPC-E
บาร์โค้ด 2 มิติ: QRCode, DataMatrix, PDF417, Aztec, MaxiCode
Notes
- ใช้ไลบรารี zxing-wasm สำหรับตรวจจับบาร์โค้ด
- รูปภาพที่มีคำอธิบายกำกับจะซ้อนกล่องขอบเขตรูปหลายเหลี่ยมสีและป้ายกำกับที่มีหมายเลขบนบาร์โค้ดที่ตรวจพบแต่ละอัน
- ตรวจจับได้สูงสุด 255 บาร์โค้ดในรูปภาพเดียว
- หากไม่พบบาร์โค้ด
barcodesจะเป็นอาร์เรย์ว่าง และannotatedUrlจะเป็น null - โหมด
tryHarderทำการสแกนอย่างละเอียดมากขึ้นโดยแลกกับเวลาประมวลผล ปิดใช้งานเพื่อประมวลผลบาร์โค้ดที่สะอาดและจัดวางเรียบร้อยได้เร็วขึ้น - เอาต์พุตที่มีคำอธิบายกำกับเป็นรูปแบบ PNG เสมอ
- อินพุต HEIC, RAW, PSD และ SVG จะถูกถอดรหัสอัตโนมัติก่อนสแกน
- ทิศทาง EXIF จะถูกนำมาใช้อัตโนมัติก่อนประมวลผล
