getSize(); // Generate high-quality PNG $moduleSize = 20; $quietZone = 4; $canvasSize = ($size + 2 * $quietZone) * $moduleSize; echo "Matrix: {$size}x{$size}\n"; echo "Module size: {$moduleSize}px\n"; echo "Quiet zone: {$quietZone} modules\n"; echo "Canvas: {$canvasSize}x{$canvasSize}px\n\n"; $image = imagecreatetruecolor($canvasSize, $canvasSize); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); imagefill($image, 0, 0, $white); $offset = $quietZone * $moduleSize; for ($row = 0; $row < $size; $row++) { for ($col = 0; $col < $size; $col++) { if ($matrix->getModuleAt($row, $col)->isDark()) { $x = $offset + ($col * $moduleSize); $y = $offset + ($row * $moduleSize); imagefilledrectangle( $image, $x, $y, $x + $moduleSize - 1, $y + $moduleSize - 1, $black ); } } } $outputDir = __DIR__ . '/test-qrcodes'; $filepath = $outputDir . '/scannable-hello-world.png'; imagepng($image, $filepath, 0); echo "✅ PNG generated: {$filepath}\n"; echo " Size: {$canvasSize}x{$canvasSize}px\n"; echo " File size: " . filesize($filepath) . " bytes\n\n"; echo "This PNG should be scannable.\n"; echo "Please test it with your smartphone scanner.\n";