Tiff file processing error

  1. Created tiff file - converted PDF to Tiff using PDFElement 6

  2. My codes:
    string POM_PhysicalPath = “C:/BarcodeTest/PrintedBillsWithPOM.tiff”;
    FileInfo file = new FileInfo(POM_PhysicalPath); // check if file is valid
    try
    {
    BarCodeReader reader = new BarCodeReader(POM_PhysicalPath, DecodeType.QR);
    while (reader.Read())
    {
    Message+=reader.GetCodeText() + " Type: " + reader.GetCodeType()+" ";
    Message = Message + "CodeText: " + reader.GetCodeText();
    float percent = reader.GetRecognitionQuality();
    }
    reader.Close();
    }
    catch (Exception ex)
    {
    Message = ex.Message;
    }
    Got error:
    {System.ArgumentException: Can’t decode image.
    at …ctor(Stream )
    at Aspose.BarCode.Bitmap…ctor(String filePath)
    at Aspose.BarCode.BarCodeRecognition.BarCodeReader…ctor(String filename, BaseDecodeType type)
    at PDF_WebTest.Pages.AposteBarCodeModel.OnGet() in C:\Users\julpa\source\repos\PDF_WebTest\PDF_WebTest\Pages\AposteBarCode.cshtml.cs:line 33}

  3. When I converted PDF to PNG, Aspose.BarCode reader is working properly

@julpalt3,

Thank you for sharing details. Please forward us the sample PDF and converted TIFF files. This will help us to reproduce the issue at our end. Kindly ZIP the samples and attach it with reply to this post.

BarcodeTiffProblem.zip (285.4 KB)
Please see attachment

@julpalt3,

Thank you for sharing samples with us. We have tried to recognize the barcode from TIFF image that you have shared. We are able to recognize the barcode successfully. Your code sample needs to be change a bit. Sample code snippet that we have used is given below along with output for your reference.

CODE:

        var img = Image.FromFile(@"PrintedBillsWithPOM.tiff");
        int totalFrame = img.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
        for (int i = 0; i < totalFrame; i++)
        {
            var w = img.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i);
            var bitmap = new Bitmap(img);
            Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(bitmap);
            
            while (reader.Read())
            {
                Console.WriteLine(reader.GetCodeText() + " " + reader.GetCodeType());
            }
        }

OUTPUT:

Code Text : ABIS**POM**::ClinicID=3##PatientID=6##Bill_num=C00012## 
Code Type : QR

Hello!
In what dll the Image.FromFile located?
When I use System.Drawing.Image.FromFile, I am getting error wing Aspose.BarCode.Bitmap object:
var img = System.Drawing.Image.FromFile(@“PrintedBillsWithPOM.tiff”);
int totalFrame = img.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page);
for (int i = 0; i < totalFrame; i++)
{
var w = img.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i);
var bitmap = new Aspose.BarCode.Bitmap(img);
Aspose.BarCode.BarCodeRecognition.BarCodeReader reader = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(bitmap);

            while (reader.Read())
            {
                Console.WriteLine(reader.GetCodeText() + " " + reader.GetCodeType());
            }
        }

@julpalt3,

It is System.Drawing. The complete line of code will be:

System.Drawing.Image img = System.Drawing.Image.FromFile(@"PrintedBillsWithPOM.tiff");

Please use the latest version of Aspose.BarCode for .NET. It will work. In case the issue persists, forward us the sample project demonstrating the issue. We will evaluate it and update you about our findings.