Created
November 11, 2009 16:25
-
-
Save uKev/232086 to your computer and use it in GitHub Desktop.
simple script creates tiles of a picture. Works well for splitting an image into many parts e.g. for an imprint of a website to make it more complicated for spammer to collect data. It creates the html code for the composition as well. Created by Manuel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
simple script creates tiles of a picture. Works well for splitting an image into many parts e.g. for an imprint of a website to make it more complicated for spammer to collect data. | |
It creates the html code for the composition as well. | |
Created by Manuel Lausch | |
(http://hs.no-ip.info) | |
Live Example: http://manuellausch.de/impressum.html | |
*/ | |
$src = imagecreatefrompng($bild); | |
$x = imagesX($src); | |
$y = imagesY($src); | |
$dst = imagecreatetruecolor($dx, $dy); | |
umask(0133); | |
echo "orginal image: $x x $y <br>"; | |
$cy = 0; | |
$i = 0; | |
do | |
{ | |
$cx = 0; | |
do | |
{ | |
if(($cx + $dx) > $x) $w = $dx-(($cx+$dx)-$x); else $w = $dx; | |
if(($cy + $dy) > $y) $h = $dy-(($cy+$dy)-$y); else $h = $dy; | |
echo "$w x $h <br>"; | |
$dst = imagecreatetruecolor($w,$h); | |
imageCopy($dst, $src, 0,0, $cx,$cy, $w,$h); | |
// imagePNG($dst, "img_" . ($cx / $dx) . "x" . ($cy / $dy) . ".png"); | |
imagePNG($dst, "img_" . $i .".png"); | |
imagedestroy($dst); | |
$i++; | |
$cx += $dx; | |
} while ($cx < $x); | |
$cy += $dy; | |
} while ($cy < $y); | |
imagedestroy($src); | |
for($j = 0; $j < $i; $j++) | |
{ | |
$sum[$j] = md5_file("img_" . $j . ".png"); | |
} | |
echo "<pre>";print_r($sum);echo "</pre>"; | |
echo "tiles: " . $cx / $dx . " x " . $cy / $dy; | |
$file = fopen("display.html", "w"); | |
fwrite($file, "<html><body><table border=1 cellspacing=0 cellpadding=0 style=\"border-collapse: collapse\">\n"); | |
$i=0; | |
for($y = 0; $y < (($cy) / $dy); $y++) | |
{ | |
fwrite($file, "<tr>\n"); | |
for($x = 0; $x < (($cx) / $dx); $x++) | |
{ | |
$p = array_search($sum[$i], $sum); | |
// fwrite($file, "<td><img src=img_" . $x ."x" . $y . ".png></td>\n"); | |
fwrite($file, "<td><img src=img_" . $p . ".png></td>\n"); | |
$i++; | |
} | |
fwrite($file, "</tr>\n"); | |
} | |
fwrite($file, "</table></body></html>"); | |
fclose($file); | |
echo "finished"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment