How to Fix Barcode Orientation

by Chaknith Bin

Barcode orientation refers to the angle at which a barcode is printed or displayed on a product or document. It can be adjusted to various angles to fit different layout and design requirements. The most common orientation is horizontal, where the barcode is aligned from left to right, which is the standard and most widely used format. Any non-zero orientation degree poses a challenge for libraries to detect and retrieve the value. IronBarcode offers automatic orientation correction to detect any non-zero orientations for barcodes and QR codes.

C# NuGet Library for

Install with NuGet

Install-Package BarCode
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

C# NuGet Library for

Install with NuGet

Install-Package BarCode
or
Java PDF JAR

Download DLL

Download DLL

Manually install into your project

Start using IronPDF in your project today with a free trial.

First Step:
green arrow pointer

Check out IronBarcode on Nuget for quick installation and deployment. With over 8 million downloads, it's transforming with C#.

C# NuGet Library for nuget.org/packages/BarCode/
Install-Package BarCode

Consider installing the IronBarcode DLL directly. Download and manually install it for your project or GAC form: IronBarCode.zip

Dll Img related to How to Fix Barcode Orientation

Manually install into your project

Download DLL

Fix Barcode Orientation Example

To apply automatic orientation correction, set the AutoRotate property in BarcodeReaderOptions to true. This property is set to true by default, so you should not have to do anything. Reading any non-zero oriented barcode image should work out of the box.

Let's use the image below as our sample. Download the following 20° rotation and 45° rotation sample images.

20° Rotation
45° Rotation

Code

:path=/static-assets/barcode/content-code-examples/how-to/image-orientation-correct-autorotate.cs
using IronBarCode;
using System;

BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Turn on auto rotation in ML detection
    AutoRotate = true,
};

var results = BarcodeReader.Read("rotate20.png", myOptionsExample);

// Print out the value
Console.WriteLine(results[0].Value);
Imports IronBarCode
Imports System

Private myOptionsExample As New BarcodeReaderOptions() With {.AutoRotate = True}

Private results = BarcodeReader.Read("rotate20.png", myOptionsExample)

' Print out the value
Console.WriteLine(results(0).Value)
VB   C#

In many cases, correcting rotation may not be sufficient, and a filter is required. Learn how to use image filters in the following article: "How to use Image Correction Filters."

Chaknith related to Code

Chaknith Bin

Software Engineer

Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking.