116 lines
3.3 KiB
PHP
116 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* generate_door_code_image.php
|
|
* Ultra-complex door code with 61 elements (31 bars + 30 gaps)
|
|
* Mix of very thin (1-unit) and thick bars — thin bars degrade badly
|
|
* when photographed, making photo-duplication unreliable.
|
|
*
|
|
* BLACK on WHITE only. No text, no border, no decoration.
|
|
*/
|
|
|
|
$width = 800;
|
|
$height = 350;
|
|
$img = imagecreatetruecolor($width, $height);
|
|
|
|
$white = imagecolorallocate($img, 255, 255, 255);
|
|
$black = imagecolorallocate($img, 0, 0, 0);
|
|
imagefill($img, 0, 0, $white);
|
|
|
|
// ═══════════════════════════════════════════════════════════════
|
|
// ULTRA-COMPLEX 61-ELEMENT PATTERN
|
|
// 31 black bars + 30 white gaps
|
|
// Mix of very thin (1-unit) and thick bars
|
|
// Thin bars will be destroyed by camera-to-camera degradation
|
|
// ═══════════════════════════════════════════════════════════════
|
|
$pattern = [
|
|
3, // bar (thick)
|
|
1, // gap (thin)
|
|
1, // bar (very thin)
|
|
1, // gap (very thin)
|
|
4, // bar (extra thick)
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
2, // gap
|
|
2, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
3, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
2, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
3, // gap
|
|
5, // bar (widest)
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
2, // gap
|
|
3, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
2, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
4, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
2, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
3, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
2, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
2, // gap
|
|
4, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
2, // bar
|
|
1, // gap
|
|
1, // bar (very thin)
|
|
1, // gap
|
|
3, // bar (thick end)
|
|
];
|
|
|
|
$totalUnits = array_sum($pattern); // = 97
|
|
$margin = 30;
|
|
$availableWidth = $width - (2 * $margin);
|
|
$unitWidth = $availableWidth / $totalUnits;
|
|
|
|
$topMargin = 25;
|
|
$bottomMargin = 25;
|
|
$barHeight = $height - $topMargin - $bottomMargin;
|
|
|
|
$x = $margin;
|
|
foreach ($pattern as $i => $units) {
|
|
$barW = max(1, round($units * $unitWidth)); // minimum 1px
|
|
if ($i % 2 === 0) {
|
|
imagefilledrectangle($img, (int)$x, $topMargin, (int)($x + $barW - 1), $topMargin + $barHeight - 1, $black);
|
|
}
|
|
$x += $barW;
|
|
}
|
|
|
|
$outputPath = __DIR__ . '/images/door_code.png';
|
|
imagepng($img, $outputPath, 0); // no compression for sharp lines
|
|
imagedestroy($img);
|
|
|
|
echo "✅ Ultra-complex door code generated: images/door_code.png (" . filesize($outputPath) . " bytes)\n";
|
|
echo "Pattern elements: " . count($pattern) . " (31 bars + 30 gaps)\n";
|
|
echo "Total units: $totalUnits, Unit width: " . round($unitWidth, 2) . "px\n";
|
|
echo "Very thin bars (1-unit) = " . round($unitWidth, 1) . "px — will degrade on photo\n";
|
|
echo "<br><br><img src='images/door_code.png' style='max-width:100%; border:1px solid #eee;'>";
|