Giter Club home page Giter Club logo

Comments (4)

masi avatar masi commented on June 2, 2024

@nbulanakov It has been resolved for HTML and SVG not for PNG.
There are forks around that add exactly this feature.

@casperbakker I don't quite get why the scaling factor is an integer. The actual width in the code is even passed to round() which results a float. Changing the argument to float will not make any difference inside the generating code, but will allow users a more fine grained control over the width.

Anyway, thanks for the code. Besides this small issue the package made my life easier.

from php-barcode-generator.

casperbakker avatar casperbakker commented on June 2, 2024

I don't see why it would be useful, while it can generate a lot of render bugs. The JPG and PNG renderer does not do any anti-aliasing, so it cannot support 1.3 pixels as a bar width. Yes, it is being rounded. But if it results in 1.3 for 1 bar, and 2.6 for 2 bars, you get 1px and 3px bars instead of 1px and 2px. That is wrong. Probably will mostly work on the barcode decoder end, but if the physical barcode is also a bit damaged, this slight bug can make the barcode not read at all.

If you want 1.3 as a factor, it is better to use 2 as a factor and render the resulting image smaller. That way the bars are the proper width in comparison, but the image renderer will make it anti aliased. For example, if you get an resulting image of 170px wide, render it at 130px wide.

But maybe I don't understand the use case that you have, which could change my view. Could you explain to me why it is difficult to work with the current integer setup, and what specific use cases would be better with a float as input. And please explain to me why it will not lead to render bugs.

from php-barcode-generator.

masi avatar masi commented on June 2, 2024

Seems I haven't fully understood the algorithm. But at least I am not alone, at least @shaunluedeke and @luisbmemorandum made the same mistake.

So you suggest to take the generated image as an intermediate step and scale it by some other means (a renderer of my choice)? Ok, not extremely difficult, but not so convenient as a one stop shop :)

As for the use case: you described it very well. The image with a factor of 2 is too large, so 1.x would come in handy.

I see your point. If I had filed the ticket you could close it.

from php-barcode-generator.

casperbakker avatar casperbakker commented on June 2, 2024

Seems I haven't fully understood the algorithm.

No problem, we are here all to learn, including me. :)

So you suggest to take the generated image as an intermediate step and scale it by some other means (a renderer of my choice)? Ok, not extremely difficult, but not so convenient as a one stop shop :)

To be clear: I don't suggest to take another tool (like Imagick) and resize the image afterwards. But if you use the barcode, you will display it somewhere and it will be rendered somewhere. Maybe in a webpage, maybe in a PDF document. In that place you can use it like <img src="generated-barcode-image.jpg" style="width: 130px">, and that will get you the right size.

If I use barcodes on printed documents, I will usually create an image 3 times bigger and display it smaller, so it will be printed as sharp as possible. This is because printers have a better resolution then monitors.

from php-barcode-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.