-
Notifications
You must be signed in to change notification settings - Fork 239
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
Exception: EGENERATE_IMAGE-2: Image size... less than 1 pixel #85
Comments
Hi @kinguru This means that the default width of the image which var b = new BarcodeLib.Barcode();
using (var img = b.Encode(BarcodeLib.TYPE.CODE128, jobGUID.ToString(), 500, 150)) {
} If you still get the same error, increase the number 500 more drastically. Perhaps 750. You will get a large image, but it should at least work at some point ;-). |
The case is that I need minimum width barcode :) I know it is 420-450 px but could vary... As I understand there is no reason for you to limit it to some default value (300?) as you should already know the length of barcode generated. |
@kinguru I see. It looks like you should be able to do this with the var barcode = new BarcodeLib.Barcode()
{
// Use the minimum bar width of 1 pixel. Setting this causes
// BarcodeLib to ignore the Width property and create the minimum-width
// barcode.
BarWidth = 1,
};
using var image = barcode.Encode(BarcodeLib.TYPE.CODE128, Guid.NewGuid().ToString());
using var outputStream = System.IO.File.OpenWrite("image.png");
image.Save(outputStream, System.Drawing.Imaging.ImageFormat.Png); Some image widths I got were 607px, 541px, and 563px—seems like it is a variable width encoding ;-). |
this error is valid in that it lets you know you are trying to generate an image smaller than it can draw it. It cant draw bars less than 1 pixel so if it determines the width of the barcode wont hold the whole image when drawing 1px width bars ... it throws this. (As @binki alluded to) |
@binki Im gonna close this out unless you think we should leave this open? |
@barnhill It looks ready to be closed to me, please go ahead! |
Closing this as answered |
Hi!
I'm calling a lib like shown below on the screenshot and getting exception about 1px.
How should I generate a barcode?
Thank you
The text was updated successfully, but these errors were encountered: