We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Barcode reading goes infinitely and keeps the cpu utilization high

Below is the code snippet which we are used for reading the barcode from tiff file, the portion which is highlighted in red color is the area which causing the issue, once the control get into the method it won’t come out and makes the process utilizing the cpu resource infinitely. Image which is causing the issue is attached with this mail.

private static string ReadBarcodeFromTiff(IList<string> images){

string FileName;

Image img = null;

FrameDimension dimension = null;

BarCodeReader rd = null;

string barcodeValue = string.Empty;

Bitmap image=null;

try

{

foreach (var imges in images)

{

FileName = FileFolder + imges;

string extension = Path.GetExtension(FileName);

if (extension != null)

{

img = Image.FromFile(FileName, true);

Guid guid = img.FrameDimensionsList[0];

dimension = new FrameDimension(guid);

int totalFrame = img.GetFrameCount(dimension);

image=new Bitmap(img);

rd=new BarCodeReader(image, type: BarCodeReadType.Code39Standard|BarCodeReadType.Code39Extended|BarCodeReadType.Code128);

for (int i = 0; i < totalFrame; i++)

{

img.SelectActiveFrame(dimension, i);

while (rd.Read())

{

barcodeValue = rd.GetCodeText();

}

}

}

}

}

catch (Exception ex)

{

ILogger logger = new Logger();

logger.LogError(ex);

}

finally

{

if(image!=null)

{

image.Dispose();

}

if(rd!=null)

{

rd.Dispose();

}

if (img != null)

{

img.Dispose();

}

}

return barcodeValue;

}

Please help me in resolving this issue.

Thanks in advance.

Hi


Thank you for your inquiry. Please clarify that, are you testing it using the latest version of Aspose.BarCode for .NET 6.6.0? If not, then please use the latest version, because it includes a number of fixes, new features and enhancements. The performance factor depends upon the file complexity, RAM and the size of the image you are trying to open/manipulate. We have added many features and optimized the code from time to time. In your case, we have tested your sample barcode and source code against the latest build of Aspose.BarCode 6.6.0. It’s working fine on our side. It takes 2.5 seconds to scan and does not consume more than 80 MB of RAM.

We hope, this helps. Please feel free to reply us in case of any confusion or questions.