EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking New
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra New

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


Image to ASCII

By: winkleer  -  Date Submitted: 2008-12-01 07:45:44

  1. <font color="black" size="0.1px" style="line-height: 0.1px;">
  2. <pre>
  3. <?php
  4.  
  5. // Simple image to ASCII by winkleer
  6.  
  7. function error()
  8. {
  9. die(" <br />nERROR. <br />n");
  10. }
  11.  
  12.  
  13. $image = "moo.jpg"; // image here, in same dir
  14.  
  15. $info = getimagesize($image);
  16.  
  17. if($info==false)
  18. {
  19. error();
  20. }
  21.  
  22. $x1=$info[0];
  23. $y1=$info[1];
  24.  
  25. if($x1+$y1>5000) // too big m8
  26. {
  27. error();
  28. }
  29.  
  30.  
  31. $im = fopen($image, "r");
  32.  
  33. while($foo=fgets($im))
  34. {
  35. $imagedata.=$foo;
  36. }
  37. // echo $im;
  38.  
  39. fclose($im);
  40.  
  41. // echo $imagedata;
  42. $imagedata=imagecreatefromstring($imagedata);
  43.  
  44. if($imagedata==false)
  45. {
  46. error();
  47. }
  48.  
  49.  
  50. $y=0;
  51. while($y<$y1)
  52. {
  53. $x=0;
  54.  
  55. while($x<$x1)
  56. {
  57.  
  58. $rgb = imagecolorat($imagedata, $x, $y);
  59. $rgb = imagecolorsforindex($imagedata, $rgb);
  60.  
  61. $total = $rgb['red']+$rgb['green']+$rgb['blue'];
  62.  
  63. if($total <= 100)
  64. {
  65. echo chr(35); // #
  66. }
  67. elseif($total <= 250)
  68. {
  69. echo chr(37);
  70. }
  71. elseif($total <= 350)
  72. {
  73. echo chr(63);
  74. }
  75. elseif($total <= 450)
  76. {
  77. echo chr(42);
  78. }
  79. elseif($total > 450)
  80. {
  81. echo" ";
  82. }
  83.  
  84. // echo $rgb['red']." ".$rgb['green']." ".$rgb['blue']." <br />n";
  85.  
  86. $x++;
  87.  
  88. }
  89. echo " <br />n";
  90.  
  91. $y++;
  92. }
  93.  
  94. ?>
  95. </pre>
  96. </font>
Return to php category list

Who's Online

415 Guests, 95 Users
vapour, Ausome1, _InSane_, hemiptera, LordHelmet, BnE, N4g4c3N, chrbarrol, ThaKeeper, dark_void, th3punish3r, locust, c0re, iwanlearn, Anderl, ghostraider100, Ghostrider, eliking510, harsha2hack, NotMyOwn, Calumoo, MajorDeath, Rex_Mundi, sabre725, bhoang93, r!v3rTw!ggz, jarlskov, invas10n, snozzberries, Nusquam-Redono-Sapientia, data, zeth, psychomarine, yuka, DnA-Ender, 454447415244, Ultraminor, T-Metal, antibubbles, raven001, aVoid, Psiber_Syn, sirEgghead, Protagoras, niggletandco, Vahakn, Chaplin, BinaryShinigami, zoegeorgica, hacker807, Red_beard, eviscerator, TheFender, InjectioN, totalnoob, Posix, obrigadoo, cul8er, Mcasdf, teehee, Ops, Protest123, Blizer, gabel, Marian, Edika, zofy, Nasrudin, dochaley, TheRetech, j0sh, kcaz, klesco, cool.nik, Sand, SaMTHG, fawk3s, rajabaja, avalor, hettoo, mat_2010, barbseven, daandeveloper33, tommy1092, Likantrop7, sajan619, Knuppel, Distorted, Bloodmaster25, blink_212, buffer, apablo, d0cketts, Y34RZ3R0, freakazoid