Предоставленный вами код написан на PHP и генерирует QR-код размером 200 пикселей, содержащий URL-адрес ” https://jabakule.com “. Ниже приведены несколько других методов, которые можно использовать для создания QR-кодов с использованием разных языков программирования:
-
Python (с использованием библиотеки qrcode):
import qrcode qr = qrcode.QRCode(version=1, box_size=10, border=4) qr.add_data('https://jabakule.com') qr.make(fit=True) image = qr.make_image(fill_color="black", back_color="white") image.save("qrcode.png") -
JavaScript (с использованием библиотеки QRCode.js):
var qrcode = new QRCode(document.getElementById("qrcode"), { text: "https://jabakule.com", width: 128, height: 128 }); -
Ruby (с использованием драгоценного камня rqrcode):
require 'rqrcode' qrcode = RQRCode::QRCode.new('https://jabakule.com', :size => 10, :level => :h) png = qrcode.as_png(size: 200) IO.write("qrcode.png", png.to_s) -
Java (с использованием библиотеки ZXing):
import com.google.zxing.EncodeHintType; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import com.google.zxing.qrcode.decoder.Mode; import com.google.zxing.qrcode.encoder.QRCode; import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class QRCodeGenerator { public static void main(String[] args) { String text = "https://jabakule.com"; int size = 200; Map<EncodeHintType, Object> hints = new HashMap<>(); hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); hints.put(EncodeHintType.MARGIN, 1); try { QRCodeWriter writer = new QRCodeWriter(); BitMatrix bitMatrix = writer.encode(text, BarcodeFormat.QR_CODE, size, size, hints); BufferedImage qrImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); qrImage.createGraphics(); Graphics2D graphics = (Graphics2D) qrImage.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, size, size); graphics.setColor(Color.BLACK); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (bitMatrix.get(i, j)) { graphics.fillRect(i, j, 1, 1); } } } ImageIO.write(qrImage, "png", new File("qrcode.png")); } catch (Exception e) { e.printStackTrace(); } } }