Last active
March 14, 2016 00:24
-
-
Save jamiebicknell/9964033 to your computer and use it in GitHub Desktop.
Revisions
-
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
jamiebicknell revised this gist
Apr 3, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ <?php function dHashAlt($file) { $hash = ''; $size = 8; list($w, $h, $t) = getimagesize($file); $im = imagecreatetruecolor($size + 1, $size); imagefilter($im, IMG_FILTER_GRAYSCALE); -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ <?php function dHash($file, $size = 8) { $hash = ''; list($w, $h, $t) = getimagesize($file); $im = imagecreatetruecolor($size + 1, $size); imagefilter($im, IMG_FILTER_GRAYSCALE); switch($t) { case 1: @@ -17,13 +17,13 @@ function dhash($file, $size = 8) $oi = imagecreatefrompng($file); break; } imagecopyresampled($im, $oi, 0, 0, 0, 0, $size + 1, $size, $w, $h); imagedestroy($oi); for ($y = 0; $y < $size; $y++) { $val = 0; for ($x = 0; $x < $size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x + 1, $y); $val += ($curr > $next) ? pow(2, ($x + ($y * $size)) % 8) : 0; } $hash .= str_pad(dechex($val), 2, 0, STR_PAD_LEFT); 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ <?php function dHashAlt($file, $size = 8) { $hash = ''; list($w, $h, $t) = getimagesize($file); $im = imagecreatetruecolor($size + 1, $size); imagefilter($im, IMG_FILTER_GRAYSCALE); switch($t) { case 1: @@ -17,13 +17,13 @@ function dhash_alt($file, $size = 8) $oi = imagecreatefrompng($file); break; } imagecopyresampled($im, $oi, 0, 0, 0, 0, $size + 1, $size, $w, $h); imagedestroy($oi); for ($y = 0; $y < $size; $y++) { $val = ''; for ($x = 0; $x < $size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x + 1, $y); $val .= ($curr > $next) ? 1 : 0; } $hash .= str_pad(dechex(bindec($val)), 2, 0, STR_PAD_LEFT); -
jamiebicknell revised this gist
Apr 3, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ function dhash($file, $size = 8) for ($x = 0; $x < $size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x+1, $y); $val += ($curr > $next) ? pow(2, ($x + ($y * $size)) % 8) : 0; } $hash .= str_pad(dechex($val), 2, 0, STR_PAD_LEFT); } -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,9 +19,9 @@ function dhash($file, $size = 8) } imagecopyresampled($im, $oi, 0, 0, 0, 0, $size+1, $size, $w, $h); imagedestroy($oi); for ($y = 0; $y < $size; $y++) { $val = 0; for ($x = 0; $x < $size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x+1, $y); $val += ($curr > $next) ? pow(2, ($x+($y*$size))%8) : 0; 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 charactersOriginal file line number Diff line number Diff line change @@ -19,9 +19,9 @@ function dhash_alt($file, $size = 8) } imagecopyresampled($im, $oi, 0, 0, 0, 0, $size+1, $size, $w, $h); imagedestroy($oi); for ($y = 0; $y < $size; $y++) { $val = ''; for ($x = 0; $x < $size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x+1, $y); $val .= ($curr > $next) ? 1 : 0; -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 24 additions and 23 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,11 @@ <?php function dhash($file, $size = 8) { $hash = ''; list($w, $h, $t) = getimagesize($file); $im = imagecreatetruecolor($size+1, $size); imagefilter($im, IMG_FILTER_GRAYSCALE); switch($t) { case 1: $oi = imagecreatefromgif($file); @@ -16,16 +17,16 @@ function dhash($file, $size = 8) { $oi = imagecreatefrompng($file); break; } imagecopyresampled($im, $oi, 0, 0, 0, 0, $size+1, $size, $w, $h); imagedestroy($oi); for ($y=0; $y<$size; $y++) { $val = 0; for ($x=0; $x<$size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x+1, $y); $val += ($curr > $next) ? pow(2, ($x+($y*$size))%8) : 0; } $hash .= str_pad(dechex($val), 2, 0, STR_PAD_LEFT); } imagedestroy($im); return $hash; 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ <?php function dhash_alt($file, $size = 8) { $hash = ''; list($w, $h, $t) = getimagesize($file); $im = imagecreatetruecolor($size+1, $size); imagefilter($im, IMG_FILTER_GRAYSCALE); switch($t) { case 1: $oi = imagecreatefromgif($file); @@ -17,16 +17,16 @@ function dhash_alt($file) { $oi = imagecreatefrompng($file); break; } imagecopyresampled($im, $oi, 0, 0, 0, 0, $size+1, $size, $w, $h); imagedestroy($oi); for ($y=0; $y<$size; $y++) { $val = 0; for ($x=0; $x<$size; $x++) { $curr = imagecolorat($im, $x, $y); $next = imagecolorat($im, $x+1, $y); $val .= ($curr > $next) ? 1 : 0; } $hash .= str_pad(dechex(bindec($val)), 2, 0, STR_PAD_LEFT); } imagedestroy($im); return $hash; -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ function dhash($file, $size = 8) { $hash = ''; list($w,$h,$t) = getimagesize($file); $im = imagecreatetruecolor($size+1,$size); imagefilter($im,IMG_FILTER_GRAYSCALE); switch($t) { case 1: $oi = imagecreatefromgif($file); 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 charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,7 @@ function dhash_alt($file) { $hash = ''; list($w,$h,$t) = getimagesize($file); $im = imagecreatetruecolor($size+1,$size); imagefilter($im,IMG_FILTER_GRAYSCALE); switch($t) { case 1: $oi = imagecreatefromgif($file); -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 2 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,6 +29,4 @@ function dhash_alt($file) { } imagedestroy($im); return $hash; } 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 charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,4 @@ function dhash($file, $size = 8) { } imagedestroy($im); return $hash; } -
jamiebicknell revised this gist
Apr 3, 2014 . 2 changed files with 6 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,4 +29,6 @@ function dhash_alt($file) { } imagedestroy($im); return $hash; } ?> 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 charactersOriginal file line number Diff line number Diff line change @@ -28,4 +28,6 @@ function dhash($file, $size = 8) { } imagedestroy($im); return $hash; } ?> -
jamiebicknell renamed this gist
Apr 3, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jamiebicknell created this gist
Apr 3, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ <?php function dhash_alt($file) { $size = 8; // Needs to be 8 for straight bin -> dec -> hex conversion $hash = ''; list($w,$h,$t) = getimagesize($file); $im = imagecreatetruecolor($size+1,$size); switch($t) { case 1: $oi = imagecreatefromgif($file); break; case 2: $oi = imagecreatefromjpeg($file); break; case 3: $oi = imagecreatefrompng($file); break; } imagecopyresampled($im,$oi,0,0,0,0,$size+1,$size,$w,$h); imagedestroy($oi); for($y=0;$y<$size;$y++) { $val = ''; for($x=0;$x<$size;$x++) { $curr = imagecolorat($im,$x,$y); $next = imagecolorat($im,$x+1,$y); $val .= ($curr > $next) ? 1 : 0; } $hash .= str_pad(dechex(bindec($val)),2,0,STR_PAD_LEFT); } imagedestroy($im); return $hash; } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <?php function dhash($file, $size = 8) { $hash = ''; list($w,$h,$t) = getimagesize($file); $im = imagecreatetruecolor($size+1,$size); switch($t) { case 1: $oi = imagecreatefromgif($file); break; case 2: $oi = imagecreatefromjpeg($file); break; case 3: $oi = imagecreatefrompng($file); break; } imagecopyresampled($im,$oi,0,0,0,0,$size+1,$size,$w,$h); imagedestroy($oi); for($y=0;$y<$size;$y++) { $val = 0; for($x=0;$x<$size;$x++) { $curr = imagecolorat($im,$x,$y); $next = imagecolorat($im,$x+1,$y); $val += ($curr > $next) ? pow(2,($x+($y*$size))%8) : 0; } $hash .= str_pad(dechex($val),2,0,STR_PAD_LEFT); } imagedestroy($im); return $hash; }