getQrSize(); $final = $qrCode->getFinal(); if ($qrCode->isBorderDisabled()) { $minSize = 4; $maxSize = $qrSize - 4; } else { $minSize = 0; $maxSize = $qrSize; } $size = $w; $s = $size / ($maxSize - $minSize); $im = imagecreatetruecolor($size, $size); $foregroundColor = imagecolorallocate($im, $color[0], $color[1], $color[2]); $backgroundColor = imagecolorallocate($im, $background[0], $background[1], $background[2]); imagefilledrectangle($im, 0, 0, $size, $size, $backgroundColor); for ($j = $minSize; $j < $maxSize; $j++) { for ($i = $minSize; $i < $maxSize; $i++) { if ($final[$i + $j * $qrSize + 1]) { imagefilledrectangle( $im, (int) round(($i - $minSize) * $s), (int) round(($j - $minSize) * $s), (int) round(($i - $minSize + 1) * $s - 1), (int) round(($j - $minSize + 1) * $s - 1), $foregroundColor ); } } } ob_start(); imagepng($im, null, $compression); $data = ob_get_contents(); ob_end_clean(); imagedestroy($im); return $data; } }