Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Won't work with UPCA barcode #71

Open
eiachh opened this issue Sep 27, 2024 · 1 comment
Open

Won't work with UPCA barcode #71

eiachh opened this issue Sep 27, 2024 · 1 comment

Comments

@eiachh
Copy link

eiachh commented Sep 27, 2024

Hi I am trying to use this lib, and it works great with QR codes and code128, but when I try to use UPCA/E or EAN8/13 it just does not work.

Could you tell me if this should work in theory?
`
file, err := os.Open("image.png")

if err != nil {
	fmt.Println("Error opening file:", err)
	return
}
defer file.Close()

img, _, err := image.Decode(file)
if err != nil {
	fmt.Println("Error decoding image:", err)
	return
}

// Prepare BinaryBitmap
bmp, err := gozxing.NewBinaryBitmapFromImage(img)
if err != nil {
	fmt.Println("Error creating BinaryBitmap:", err)
	return
}

// Decode the barcode
reader := oned.NewUPCAReader()
result, err := reader.Decode(bmp, nil)
if err != nil {
	fmt.Println("Error decoding barcode:", err)
	return
}

fmt.Println("Decoded text:", result.GetText())`

This is my image that other tools can parse easily

image

@makiuchi-d
Copy link
Owner

makiuchi-d commented Sep 30, 2024

It looks like there isn't enough white space on the right side.

I got the result with this code:

	img2 := image.NewRGBA(image.Rect(0, 0, 600, 356))
	draw.Draw(img2, img2.Bounds(), image.White, image.Pt(0, 0), draw.Over)
	draw.Draw(img2, image.Rect(0, 0, 559, 356), img, image.Pt(0, 0), draw.Over)

	// Prepare BinaryBitmap
	bmp, err := gozxing.NewBinaryBitmapFromImage(img2)

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

No branches or pull requests

2 participants