Skip to content

Instantly share code, notes, and snippets.

@bored-engineer
Created May 18, 2013 21:50
Show Gist options
  • Select an option

  • Save bored-engineer/5605895 to your computer and use it in GitHub Desktop.

Select an option

Save bored-engineer/5605895 to your computer and use it in GitHub Desktop.
<?php
$im = imagecreatefrompng("data.png");
$binary = "";
for($i=0; $i<imagesx($im); $i++){
$rgb = imagecolorat($im, $i, 0);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$r = decbin($r);
$g = decbin($g);
$b = decbin($b);
$binary .= $r[strlen($r)-1].$g[strlen($g)-1].$b[strlen($b)-1];
}
echo $binary.PHP_EOL;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment