Coder Social home page Coder Social logo

Comments (2)

zertap avatar zertap commented on July 17, 2024

Seems to work for me

$ qrencode -V
qrencode version 4.1.1
Copyright (C) 2006-2017 Kentaro Fukuchi

$ qrencode -t PNG -d 72 -o d72.png "test"
$ qrencode -t PNG -d 300 -o d300.png "test"

$ identify -verbose d72.png | grep -A3 Geometry
  Geometry: 87x87+0+0
  Resolution: 28.34x28.34
  Print size: 3.06987x3.06987
  Units: PixelsPerCentimeter

$ identify -verbose d300.png | grep -A3 Geometry
  Geometry: 87x87+0+0
  Resolution: 118.11x118.11
  Print size: 0.736601x0.736601
  Units: PixelsPerCentimeter

https://fukuchi.org/works/qrencode/
In 3.2.0 version notes:

"--dpi" (or "-d") option has been added to qrencode. This option set DPI information in an output PNG image. (Thanks to David Dahl)

The man-page or help does not seem to be as specific, but the dpi setting is metadata only. It does not affect pixel size (geometry).

-d NUMBER, --dpi=NUMBER
specify the DPI of the generated PNG. (default=72)

If you wanted to have a bigger pixel size instead to match the dpi (like I did), you can resample it with imagick

$ convert -units PixelsPerInch -interpolate Nearest -filter point -resample 300 d72.png d300-imagick-resample.png
$ identify -verbose d300-imagick-resample.png | grep -A3 Geometry
  Geometry: 363x363+0+0
  Resolution: 118.11x118.11
  Print size: 3.07341x3.07341
  Units: PixelsPerCentimeter

This yields the same "print size" as the 72 (default) dpi setting but with bigger pixel size.
the -interpolate and -filter options are needed so the resampling does not make the image blurry.
This does have the downside that the margins are also multiplied. Setting -m 0 or -m 1 with qrencode might be desired.

You can also just specify the desired pixel size : convert -interpolate Nearest -filter point -resize 500 d72.png 500px.png
For full list of options with ImageMagick's -resize see https://imagemagick.org/script/command-line-options.php#resize


So, this is not really a bug but a feature request for setting the desired pixel size and scaling the qr-code accordingly as I see it.

from libqrencode.

pd3 avatar pd3 commented on July 17, 2024

Mmm, okay. I will not question the usefulness of the --dpi option, but the only thing that ever mattered to me was the resolution of an image. That would be a useful addition!

Thank you for offering a workaround via imagemagick.

from libqrencode.

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.