Barcode.Detect
--------------

Detects a barcode.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Barcode](component_Barcode.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Barcode.Detect"; Image { ; Type; ReturnType; TryRotation; Encoding } ) 

**MBS**( **"Barcode.Detect";** /\* Detects a barcode. \*/  
**$Image**; /\* The image to scan for a barcode.   
Can be container with image or an Image reference number from our GraphicsMagick image functions. \*/   
**$Type**; /\* Optional; Which scanner to use. Supported types: Aztec, Codabar, Code39, Code93, Code128, DataMatrix, EAN8, EAN13, ITF, PDF417, QRCode, UPCA and UPCE. Pass All to scan for all types.  
Default is all.e.g. "QRCode" \*/   
**$ReturnType**; /\* Optional; A boolean to return the type as prefix. Pass 1 if you need prefix. Default is 0 for no prefix.e.g. 1 \*/   
**$TryRotation**; /\* Optional; A boolean value. If 1, the plugin will rotate the image 90° to find vertical barcode.   
Default is true.e.g. 1 \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is UTF-8.e.g. UTF8 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Image | The image to scan for a barcode.    Can be container with image or an Image reference number from our GraphicsMagick image functions. | $image |  |
| Type | Which scanner to use. Supported types: Aztec, Codabar, Code39, Code93, Code128, DataMatrix, EAN8, EAN13, ITF, PDF417, QRCode, UPCA and UPCE. Pass All to scan for all types.   Default is all. | "QRCode" | Optional |
| ReturnType | A boolean to return the type as prefix. Pass 1 if you need prefix. Default is 0 for no prefix. | 1 | Optional |
| TryRotation | A boolean value. If 1, the plugin will rotate the image 90° to find vertical barcode.    Default is true. | 1 | Optional |
| Encoding | The text encoding for text parameter.    Default is UTF-8.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | UTF8 | Optional |

### Result

Returns barcode content text or error.

### Description

Detects a barcode.  
We use zxing library internally and can only detect what this library handles.  
Internally all images are converted to grayscale. For you getting image, it's very important to get a sharp image.  
You may need to rotate or crop the image before sending into this method.  
  
Leave some white space around as some decoders don't want to start with black frame on the edge. The barcodes generated with [Barcode.Generate](BarcodeGenerate.md) often don't read as they have too little resolution (e.g. scale up by 3x) and no white border around (e.g. add 5 pixels).  
  
If special characters or umlauts are not recognized correct, you may have a wrong encoding. Most modern apps use UTF8 for encoding.  
  
For MacOS and iOS, you can also detect barcodes with [CoreImage.Detect](CoreImageDetect.md) function, which is faster and can better find a barcode on a picture.  
  
Please note that Barcode.Detect uses zxing library, which can't read all barcodes well. For that reason we got [Barcode.Scan](BarcodeScan.md) using zbar library, which may be better.  
  
For FileMaker Go, please use PSoS and do the scan server side. Or build your own app based on the FileMaker iOS SDK with Xcode and embed the MBS Plugin for on device detection.  
  
See also [Barcode.DetectAsJSON](BarcodeDetectAsJSON.md) to get more detailed output of the result.  
### Examples

Query a QRCode:

 MBS ( "Barcode.Detect"; Images::Image ; "QRCode" )  
### See also

- [AVRecorder.CaptureStillPhoto](AVRecorderCaptureStillPhoto.md)
- [AVRecorder.StartQRCodeDetection](AVRecorderStartQRCodeDetection.md)
- [Barcode.DetectAsJSON](BarcodeDetectAsJSON.md)
- [Barcode.Generate](BarcodeGenerate.md)
- [Barcode.Scan](BarcodeScan.md)
- [CoreImage.Detect](CoreImageDetect.md)
- [Vision.DetectBarcode](VisionDetectBarcode.md)

### Release notes

- **Version 14.5**
    - Added [Barcode.DetectAsJSON](https://www.mbsplugins.eu/BarcodeDetectAsJSON.shtml) function.
    - Improved [Barcode.Detect](https://www.mbsplugins.eu/BarcodeDetect.shtml) by using newer zxing library.
- **Version 12.2**
    - Deprecated [Barcode.Detect](https://www.mbsplugins.eu/BarcodeDetect.shtml) in favor of [Barcode.Scan](https://www.mbsplugins.eu/BarcodeScan.shtml) function.
- **Version 11.2**
    - Updated zxing library to get a few newer bug fixes for [Barcode.Detect](https://www.mbsplugins.eu/BarcodeDetect.shtml) function.
- **Version 8.2**
    - Changed [Barcode.Detect](http://www.mbsplugins.eu/BarcodeDetect.shtml) to report the version number read when complaining about invalid version in QRCode.
    - Fixed crash with [Barcode.Detect](http://www.mbsplugins.eu/BarcodeDetect.shtml) with out of bounds access in image for bad QRCodes.
- **Version 8.0**
    - Fixed out of bounds problem in [Barcode.Detect](http://www.mbsplugins.eu/BarcodeDetect.shtml). And now returns checksum errors properly.

### Example Databases

- [Barcode/Barcode Detection](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Barcode%20Detection.shtml#1ScriptAnchor_)
- [Barcode/Barcodes from Invoices](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Barcodes%20from%20Invoices.shtml#2ScriptAnchor_)
- [Barcode/Swiss QR-Code for invoices/Swiss QR-Code for invoices ISO 20022](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Swiss%20QR-Code%20for%20invoices/Swiss%20QR-Code%20for%20invoices%20ISO%2020022.shtml#18ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin 14.5 for Claris FileMaker](https://www.mbsplugins.de/archive/2024-11-12/MBS_FileMaker_Plugin_145_for_C/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.5pr1](https://www.mbsplugins.de/archive/2024-10-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Claris FileMaker 19.5 available](https://www.mbsplugins.de/archive/2022-06-15/Claris_FileMaker_195_available/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.2pr4](https://www.mbsplugins.de/archive/2022-04-28/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.3 - More than 6500 Functions In One Plugin](https://www.mbsplugins.de/archive/2021-07-12/MBS_FileMaker_Plugin_113_-_Mor/monkeybreadsoftware_blog_filemaker)
- [Using zbar library with FileMaker](https://www.mbsplugins.de/archive/2021-06-21/Using_zbar_library_with_FileMa/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.2pr4](https://www.mbsplugins.de/archive/2021-04-21/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Combine MBS functions to automate processes in FileMaker](https://www.mbsplugins.de/archive/2019-04-11/Combine_MBS_functions_to_autom/monkeybreadsoftware_blog_filemaker)
- [Live barcode reading for FileMaker on MacOS and iOS](https://www.mbsplugins.de/archive/2018-08-30/Live_barcode_reading_for_FileM/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 3.5 for OS X/Windows - More than 2100 Functions In One Plugin](https://www.mbsplugins.de/archive/2013-12-17/MBS_FileMaker_Plugin_35_for_OS/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2019, Seite 37](https://filemaker-magazin.de/neuigkeit/4046-Appetithappen-FMM_201903)
- [Ausgabe 5/2018, Seite 29](https://filemaker-magazin.de/neuigkeit/4011-Appetithappen-FMM_201805)

This function checks for a license.

Created 18th August 2014 , last changed 22nd September 2024

  
[Backdrop.Install](BackdropInstall.md) - [Barcode.DetectAsJSON](BarcodeDetectAsJSON.md)

[HTML Version](BarcodeDetect.shtml)