Changing Size and Border
00:00
Changing the size of the QR code. To adjust the size of the QR code, you can add a scale=
parameter to the .save()
method. The scale=
parameter is a scaling factor that changes the width and height of the QR code image.
00:14 The default value is one, and when you created your first code, the size of each black or white square in QR code was one pixel wide and one pixel high. Each of these black or white squares is called a module.
00:29 With the changes being made to the code on screen, you can create a QR code that encodes the same content, but where each module is five by five pixels inside.
00:39
In addition to the file name, the scale
argument is set changing each module to five pixels instead of the default of one.
00:49 With this file saved, it’s run from the command line in the same way as the previous example.
01:00 On screen, you can see the original and scaled QR codes. Try scanning them with your phone camera to see if there’s a difference in the response speed. Because the QR code is presented on a white background here, it’s not possible to see the blank space around it, but it is there.
01:17 As you can see when it’s placed on a non-white background. Segno allows the adjustment of this blank space so let’s take a look at that next. To increase the scanability of the QR code and make sure that devices such as smartphones can clearly access the information, Segno put some blank space around the QR code.
01:37
This blank space is referred to as the quiet zone. You also have the option of modifying the size of this quiet zone by making changes to the border=
parameter within the .save()
method. You set the size of the margin around the code by specifying an integer value to the border=
argument. By default, the size of the quiet zone is four modules on each side.
02:03
Once more, the file name is changed to allow comparison of codes and then the important addition of the border
argument. Here, it’s set to zero to remove the quiet zone from the outside of the code.
02:15 Once again, you’ll need to run the script to generate the new QR code.
02:23 For comparison, on screen you can see the two previous QR codes on the same scale, one with the default border, and one with the border set to zero. And just like that, you’ve removed the quiet zone from the QR code.
02:37 Try scanning the image and see if this has changed the response speed.
02:43
If you want to increase the size of the quiet zone and create a wider border for the QR code, you can do it by increasing the value of border
.
02:52 Here setting it to 10 makes for a wider quiet zone and easier reading by devices.
02:59 While it’s of course possible to create a quiet zone in the software used to create a flyer, poster, or other physical medium, adding it into the QR code can avoid issues with designers leaving no quiet space around the code and making recognition more difficult for the end user.
03:15 Once more, running the script will generate the QR code.
03:25 The three versions with different quiet zones, zero, four, and 10 modules are seen on screen. So far, the QR codes have all been generated with the default colors of black on white, but Segno allows control of the colors used to make up the QR code, and in the next section of the course, you’ll see how you can change the color of the background, the quiet zone, and the data modules.
Become a Member to join the conversation.