如何在现有图像上嵌入二维码?

时间:2019-03-04 07:48:15

标签: qr-code

Sample image of qr code embedded over given image

因此,我正在项目中使用二维码,我需要将二维码叠加在图像上。附有示例图片。我是从在线二维码生成器生成的。我可以使用哪些库在Web应用程序或移动应用程序中生成此类图像?

1 个答案:

答案 0 :(得分:0)

您可以使用任何编程语言提供的任何GD库。您要查找的是 Watermarking 。一些示例是:

C#

您可以使用GDI for .NET来遵循此article

PHP

直接来自manual的示例。

<?php
// Load the stamp and the photo to apply the watermark to
$stamp = imagecreatefrompng('stamp.png');
$im = imagecreatefromjpeg('photo.jpeg');

// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);

// Copy the stamp image onto our photo using the margin offsets and the photo 
// width to calculate positioning of the stamp. 
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));

// Output and free memory
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
相关问题