PHPackages                             tei187/qr-image2svg - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. tei187/qr-image2svg

ActiveLibrary[Image &amp; Media](/categories/media)

tei187/qr-image2svg
===================

Converts bitmap image-based QR codes into SVG form.

2.0.0(1y ago)131MITPHPPHP &gt;=7.4

Since Mar 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/tei187/qr-image2svg)[ Packagist](https://packagist.org/packages/tei187/qr-image2svg)[ RSS](/packages/tei187-qr-image2svg/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

[![QR image-2-svg converter](https://repository-images.githubusercontent.com/457393906/2829ff00-7eb6-45f5-871f-be9eec7e0576)](https://repository-images.githubusercontent.com/457393906/2829ff00-7eb6-45f5-871f-be9eec7e0576)

**QR image 2 SVG converter**
============================

[](#qr-image-2-svg-converter)

[DEMO APP](https://qrgen.xowergs.wirt16.bhlink.pl) *(not user friendly at the moment, looks messy, lots of reclicking)*

---

**About**
---------

[](#about)

Library meant to easily convert bitmap image-based QR codes to SVG equivalent form. Supports GD library, Imagick extension and ImageMagick command line prompts.

### **Mechanics**

[](#mechanics)

The concept here is to assign a grid over the QR image, find the center position of each generated tile and read the color value of the corresponding pixel. Then, basing on the assigned threshold value, resolve the SVG render with gathered data.

### **Story behind it**

[](#story-behind-it)

The main reason to create this solution was my day-to-day job, where I have to handle graphic files for prepress solutions. Sadly, many graphic designers still do not seem to understand that, often enough, bitmap images will offer a lower quality than their vector alternatives in print, not matter how far you will crank up the image resolution (it has to do with how images are processed by RIP systems to raster dots form). In the company I work for, we often introduce amendments to graphic files in order to receive the best possible quality in print. However, converting QR codes from bitmap to vector objects is not as easy or as fun as it should (no, contour tracing in many cases is not a viable option), so we were in need of yet another in-house solution to speed up yet another process. Came up with this package.

---

**Classes overview**
--------------------

[](#classes-overview)

**Namespace****Description**tei187\\QrImage2Svg\\**Configuration**Holds configuration for the processtei187\\QrImage2Svg\\**Processor**Abstract processor classtei187\\QrImage2Svg\\Processor\\**GD**GD library processortei187\\QrImage2Svg\\Processor\\**Imagick**Imagick extension processortei187\\QrImage2Svg\\Processor\\**ImageMagick**ImageMagick command line processortei187\\QrImage2Svg\\Processors\\ImageMagick\\**Commands**ImageMagick commands used in command prompt *(static)*tei187\\QrImage2Svg\\Resources\\**MIME**MIME types class handlers *(static)*tei187\\QrImage2Svg\\Utilities\\**PathValidator**Path validator class *(static)***Usage**
---------

[](#usage)

- ### **Installation**

    [](#installation)

    - Composer

    ```
    composer require tei187/qr-image2svg
    ```

    - Manual (package download)

    ```
      require_once( PATH_TO_EXTRACTED_PACKAGE . "/index.php" );
    ```
- ### **Configuration**

    [](#configuration)

    Configuration class holds config on which the process will be based and is required for the process to run. It involves the following:

    Parameter NameParameter TypeDescriptioninputDirstringPath to the image file to be convertedoutputDirstringPath to the directory where the converted file will be savedfilenamestringName of the input filestepsint | nullNumber of steps per axis (how many tiles/modules per axis are there in the QR image)thresholdintThreshold value (0-255)channelstringColor channel (red, green, blue)imUseMagickPrefixboolPrefix for ImageMagick commands (IM-specific)imUseConvertPrefixboolPrefix for ImageMagick commands (IM-specific)#### Example

    [](#example)

    ```
