<?php

$img = imagecreatefrompng('/var/www/html/public/qrcode-python-large.png');

$width = imagesx($img);
$height = imagesy($img);

echo "Image dimensions: {$width}x{$height}\n\n";

// Check a few known positions
$scale = 20;
$qz = 4;

// Top-left corner of finder pattern (should be black)
$x = ($qz + 0) * $scale + 10;
$y = ($qz + 0) * $scale + 10;
$rgb = imagecolorat($img, $x, $y);
$r = ($rgb >> 16) & 0xFF;
echo "Position [0,0] (finder corner): RGB=$r, " . ($r < 128 ? "Black" : "White") . "\n";

// Format info position [8,0] 
$x = ($qz + 0) * $scale + 10;
$y = ($qz + 8) * $scale + 10;
$rgb = imagecolorat($img, $x, $y);
$r = ($rgb >> 16) & 0xFF;
echo "Position [8,0] (format): RGB=$r, " . ($r < 128 ? "Black" : "White") . "\n";

// Try center of module instead
$x = ($qz + 0) * $scale + $scale/2;
$y = ($qz + 8) * $scale + $scale/2;
$rgb = imagecolorat($img, (int)$x, (int)$y);
$r = ($rgb >> 16) & 0xFF;
echo "Position [8,0] (center): RGB=$r, " . ($r < 128 ? "Black" : "White") . "\n";

