Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7034667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:12:50+00:00 2026-05-28T01:12:50+00:00

Hi, We are using imagick for different image manipulations and have a request to

  • 0

enter image description here

Hi,

We are using imagick for different image manipulations and have a request to add
QR watermarks in the end.

Right now I could only find PHP QR Code library which uses the GD2 library:

Implemented purely in PHP, no external dependencies except GD2

Is there any php snippet or library which uses imagick to create QR codes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:12:50+00:00Added an answer on May 28, 2026 at 1:12 am

    Looking at the PHP QR Code library, there is only one file (I think) that accesses the GD library: qrimage.php. So change that file to output via imagick and use the rest of PHP QR Code.

    Below is a possible imagick output file I wrote to replace qrimage.php. However, I am unable to test this code, since I am on Windows, and cannot install imagick.

    Can someone please debug it, and edit this post with any corrections?

    <?php
    /*
     * PHP QR Code encoder
     *
     * Image output of code using GD2
     *
     * PHP QR Code is distributed under LGPL 3
     * Copyright (C) 2010 Dominik Dzienia <deltalab at poczta dot fm>
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU Lesser General Public
     * License as published by the Free Software Foundation; either
     * version 3 of the License, or any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
     * Lesser General Public License for more details.
     *
     * You should have received a copy of the GNU Lesser General Public
     * License along with this library; if not, write to the Free Software
     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
     */
    
        define('QR_IMAGE', true);
    
        class QRimage {
    
            //----------------------------------------------------------------------
            public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE) 
            {
                $image = self::image($frame, $pixelPerPoint, $outerFrame, "png", 85, $filename, $saveandprint);
            }
    
            //----------------------------------------------------------------------
            public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85) 
            {
                $image = self::image($frame, $pixelPerPoint, $outerFrame, "jpeg", $q, $filename, $saveandprint);
            }
    
            //----------------------------------------------------------------------
            private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4, 
                $format = "png", $quality = 85, $filename = FALSE, $saveandprint = FALSE) 
            {
                $imgH = count($frame);
                $imgW = strlen($frame[0]);
    
                $col[0] = new ImagickPixel("white");
                $col[1] = new ImagickPixel("black");
    
                $image = new Imagick();
                $image->newImage($imgW, $imgH, $col[0]);
    
                $image->setCompressionQuality($quality);
                $image->setImageFormat($format); 
    
                $draw = new ImagickDraw();
                $draw->setFillColor($col[1]);
    
                for($y=0; $y<$imgH; $y++) {
                    for($x=0; $x<$imgW; $x++) {
                        if ($frame[$y][$x] == '1') {
                            $draw->point($x,$y); 
                        }
                    }
                }
    
                $image->drawImage($draw);
                $image->borderImage($col[0],$outerFrame,$outerFrame);
                $image->scaleImage( $imgW * $pixelPerPoint, 0 );
    
                if ($filename === FALSE) {
                    Header("Content-type: image/jpeg");
                    echo $image;
                } else {
                    if($saveandprint===TRUE){
                        $image->writeImages($filename, true);        
                        Header("Content-type: image/" . $format);
                        echo $image;
                    } else {
                        echo $image;
                    }
                }
            }    
        }
    

    There is a merged file called phpqrcode.php that contains the entire qrimage.php, so you will either have to remerge that file, or else replace the relevant section.

    If you use a different filename for the above code, you will have to change the reference in the file qrlib.php and merge.php.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an image with a caption using the Imagick::newPseudoImage function as follows:
I'm looking to center crop and image using Imagick PHP apis (not command line
I'm using Imagick lib to do some modifications to original image. Then I'd like
using Eclipse 3.4 Ganymede and I cannot find the way to add javadoc support
We have an image editor in Flex to add text and other changes. Once
Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I'm importing SVGs with imagick using this syntax $graphic = new Imagick($this->img); The problem
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using jQuery, one can easily find out whether a particular element is visible using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.