Skip to content

Conversation

@Christian-Quesada
Copy link

@Christian-Quesada Christian-Quesada commented Nov 10, 2025

  • Add Human Readable for QR Codes png and svg format, and barcode for png.
  • Update readme file to reflect the change.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to display human-readable text below barcodes and QR codes, addressing a previous limitation where text rendering wasn't possible. The implementation uses SixLabors.ImageSharp.Drawing for PNG rendering and SVG manipulation for vector output.

  • Adds new query parameter "ihr" to enable human-readable text display
  • Implements text rendering for both PNG (using ImageSharp Drawing) and SVG formats
  • Removes "Known Limitations" section about inability to render text below barcodes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
README.md Documents new ImageSharp.Drawing dependency, adds "ihr" query parameter documentation, and removes the limitation about missing text rendering
BarcodeImageService.cs Implements human-readable text rendering with two helper methods for PNG and SVG formats, adds query parameter parsing logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

h | The height, in pixels, of the rendered barcode. _Default: 40 pixels_. For QR Code, there are certain jump-points between sizes that will cause a change in the outputted image size. Each Matrix code type has symmetrical representation requirements. It will always jump to an even number that is a multiple of the codeword size.
w | The width, in pixels, of the rendered barcode. _Default: 0, which means 'unset'_ For 1D barcodes (like Code 128), leave unset to let the rendering engine decide.
m | Margins, in pixels. _Default: 0_. For 1D barcodes, this modifies the left and right margins. Top and bottom are untouched.
ihr | Set as 'True' if you want to see the human readable bellow the barcode/qr code. _Default:False
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'bellow' to 'below'.

Copilot uses AI. Check for mistakes.
h | The height, in pixels, of the rendered barcode. _Default: 40 pixels_. For QR Code, there are certain jump-points between sizes that will cause a change in the outputted image size. Each Matrix code type has symmetrical representation requirements. It will always jump to an even number that is a multiple of the codeword size.
w | The width, in pixels, of the rendered barcode. _Default: 0, which means 'unset'_ For 1D barcodes (like Code 128), leave unset to let the rendering engine decide.
m | Margins, in pixels. _Default: 0_. For 1D barcodes, this modifies the left and right margins. Top and bottom are untouched.
ihr | Set as 'True' if you want to see the human readable bellow the barcode/qr code. _Default:False
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation line is incomplete. Missing closing underscore and description text after the default value. Should be: _Default: False_. Additionally, there's a space missing after the colon in _Default:False.

Suggested change
ihr | Set as 'True' if you want to see the human readable bellow the barcode/qr code. _Default:False
ihr | Set as 'True' if you want to see the human readable below the barcode/QR code. _Default: False_.

Copilot uses AI. Check for mistakes.
byte[] bytes;

// zxing.net already add the human readable for barcodes like Code 128.
if (includeHumanReadable && string.Compare(symbologyStr, BarcodeFormat.QR_CODE.ToString(), false) == 0)
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ignoreCase parameter is set to false, which means the comparison is case-sensitive. However, on line 106, the comparison uses true (case-insensitive). This inconsistency could cause the human readable text feature to fail if the symbology string has different casing. Should use true for case-insensitive comparison to match line 106.

Suggested change
if (includeHumanReadable && string.Compare(symbologyStr, BarcodeFormat.QR_CODE.ToString(), false) == 0)
if (includeHumanReadable && string.Compare(symbologyStr, BarcodeFormat.QR_CODE.ToString(), true) == 0)

Copilot uses AI. Check for mistakes.
return new BadRequestObjectResult($"Margin 'm' must be between 0 and {maxMargin}.");
}

var includeHumanReadable = req.Query.ContainsKey("ihr") && string.Compare(req.Query["ihr"].ToString(), bool.TrueString, true) == 0;
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inefficient use of 'ContainsKey' and indexer.

Suggested change
var includeHumanReadable = req.Query.ContainsKey("ihr") && string.Compare(req.Query["ihr"].ToString(), bool.TrueString, true) == 0;
var includeHumanReadable = !StringValues.IsNullOrEmpty(req.Query["ihr"]) && string.Compare(req.Query["ihr"].ToString(), bool.TrueString, true) == 0;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants