Jump to content



Photo

Image to Text


  • Please log in to reply
51 replies to this topic

#1 NeoFoX

NeoFoX

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 08 January 2007 - 06:44 PM

Edit NEW: New functions ;) see for yourself...

Edit4: Edited a 'progress-bar'..
Edit3: Edited a '% pixel use' option..
Edit2: Edited a 'Font-size select' option..
Edit1: Made the GUI a little better and added a Time-function how-long it took to convert.

Well, after a day of scripting my result:

Select your image with the Browse-button...
Select the characters and how they will be used (random or in sequence)...
Select Color or Grayscale...
And a background color...
And at last the Contrast level...
Wait a few secs.. and tadaa :)

(At the bottom there is a link to the script, and a link to the UDF of Lazycat which I used :) )

Any comments are welcome.. this is my first offical script so don't be to rude :P


Neo
Plain Text         
#include <File.au3> #include <Guiconstants.au3> #include <image_get_info.au3> Global $i_height,$i_width,$waardes,$total,$info,$image,$contrast_value,$contrast_value_end,$size Global $procent_pixels,$pixel_atm,$value_progress,$progressbar,$progress,$progress_count,$procent Global $bg_color,$font_color,$size_ASCII $Main = GUICreate("Image to Text", 629, 363, 193, 115) GUICtrlCreateGroup("Preview Image", 8, 8, 305, 345) $Picca = GUICtrlCreatePic("", 16, 32, 225, 209) $slider_procent = GUICtrlCreateSlider (25,256,200,20) GUICtrlSetState(-1,$GUI_DISABLE) $slider_procent_text = GUICtrlCreateLabel("",230,256,50,20) $Label9 = GUICtrlCreateLabel("% of pixels", 255, 255, 50, 17) $width_test = GUICtrlCreateLabel(" ", 36, 286, 30, 17) $Label2 = GUICtrlCreateLabel("x", 64, 286, 9, 17) $height_test = GUICtrlCreateLabel(" ", 80, 286, 30, 17) $file_size = GUICtrlCreateLabel(" ", 55, 310, 30, 17) $Label5 = GUICtrlCreateLabel("Kb", 75, 310, 17, 17) $Label6 = GUICtrlCreateLabel("Pixels", 128, 286, 31, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $tab_text =GUICtrlCreateTab (320,8, 305,345) $color_grayscale = GUICtrlCreateTabitem("Color / Grayscale") $browse = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters:", 328, 72, 257, 80) $characters = GUICtrlCreateInput("Characters", 336, 92, 100, 21) $char_size = GUICtrlCreateCombo("Smallest", 450, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") $random = GUICtrlCreateRadio("Random", 336, 120, 105, 25) GUICtrlSetState($Random, $GUI_CHECKED) $Sequence = GUICtrlCreateRadio("Sequence", 456, 120, 121, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Color:", 328, 160, 257, 95) $color = GUICtrlCreateRadio("Color", 336, 176, 97, 25) $grayscale  = GUICtrlCreateRadio("Grayscale", 456, 176, 97, 25) GUICtrlSetState($color, $GUI_CHECKED) $Label7 = GUICtrlCreateLabel("Background:",336, 207, 193, 25) $bg_color = GUICtrlCreateCombo("BLACK", 336, 225, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Contrast:", 328, 260, 257, 49) $high = GUICtrlCreateRadio("High", 336, 276, 113, 25) $low = GUICtrlCreateRadio("Low", 456, 276, 113, 25) GUICtrlSetState($low, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $ok_button = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) $ASCII = GUICtrlCreateTabitem("ASCII") $browse_ASCII = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters Size:", 328, 72, 257, 50) $char_size_ASCII = GUICtrlCreateCombo("Smallest", 336, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Font/Background color:", 328, 130, 257, 120) $Label7_ASCII = GUICtrlCreateLabel("Font color:",336, 150, 193, 25) $font_color_ASCII = GUICtrlCreateCombo("BLACK", 336, 168, 193, 25) GUICtrlSetData(-1,"WHITE","WHITE") $Label7_ASCII = GUICtrlCreateLabel("Background:",336, 197, 193, 25) $bg_color_ASCII = GUICtrlCreateCombo("BLACK", 336, 215, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) $invert = GUICtrlCreateCheckbox ("Invert", 336, 260, 120, 20) $ok_button_ASCII = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) GUISetState(@SW_SHOW) While 1     $msg = GUIGetMsg()     Select     Case $msg = $GUI_EVENT_CLOSE         Exit     Case $msg = $browse         $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)")         $aInfo_test = _ImageGetInfo($file)         GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width"))         GUICtrlSetData($height_test, _ImageGetParam($aInfo_test, "Height"))         Guictrlsetdata($file_size, int(FileGetSize($file)/1000))         GUICtrlSetImage($picca,$file)         GUICtrlSetState($slider_procent,$GUI_ENABLE)         GUICtrlSetData($slider_procent,25)     case $msg = $browse_ASCII         $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)")         $aInfo_test = _ImageGetInfo($file)         GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width"))         GUICtrlSetData($height_test,_ImageGetParam($aInfo_test, "Height"))         Guictrlsetdata($file_size, int(FileGetSize($file)/1000))         GUICtrlSetImage($picca,$file)         GUICtrlSetState($slider_procent,$GUI_ENABLE)         GUICtrlSetData($slider_procent,25)     Case $msg = $ok_button         values()     case $msg = $ok_button_ASCII         values_ASCII()     EndSelect     $read_procent = GUICtrlRead($slider_procent)     GUICtrlSetData($slider_procent_text,$read_procent)     Sleep(25) WEnd func values()         Local $calc_total = 0         $aInfo = _ImageGetInfo($file)         $i_width = _ImageGetParam($aInfo, "Width")         $i_height =  _ImageGetParam($aInfo, "Height")         $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreatePic($file,0,0,$i_width,$i_height)         $pr_height = WinGetPos($image)         $progress = Guicreate("Progress",130,60,-1,$pr_height[1]-65,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreateLabel("Reading:",10,10,100,20)         $pixel_atm = GUICtrlCreateLabel("",60,10,150,20)         GUICtrlCreateLabel("/",90,10,100,20)         $pixel_total = GUICtrlCreateLabel("",100,10,100,20)         $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH)         $procent = GUICtrlCreateLabel("100",50,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlCreateLabel("%",70,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUISetState(@SW_hide,$main)         GUISetState(@SW_Show,$image)         GUISetState(@SW_Show,$progress)         $waardes = GUICtrlRead($characters)         $total = Int(StringLen($waardes))         $info = WinGetPos($image)         $read_procent = GUICtrlRead($slider_procent)         $value = 100 / $read_procent         $procent_pixels = Round($value)         if $procent_pixels = 1 Then             $procent_pixels = 2         EndIf         $pixel_total_width = GUICtrlRead($width_test)         $pixel_total_height = GUICtrlRead($height_test)         $calc_1 = round($pixel_total_width/($procent_pixels-1))         $calc_2 = round($pixel_total_height/$procent_pixels)         $calc_1_2 = $calc_1 * $calc_2         GUICtrlSetData($pixel_total,$calc_1_2)         $value_progress = 100/$calc_1_2         $r_checked = GUICtrlRead($random)         $l_checked = GuiCtrlRead($low)         $c_checked = GUICtrlRead($color)         $size_char = GUICtrlRead($char_size)         Select         case $size_char = "Smallest"             $size = "-6"         case $size_char = "Small"             $size = "-3"         case $size_char = "Normal"             $size = "1"         case $size_char = "Large"             $size = "4"         case $size_char = "Largest"             $size = "6"         EndSelect         Select         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_color_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_color_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_color_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_color_Sequence()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_grayscale_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_grayscale_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_grayscale_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_grayscale_Sequence()        EndSelect EndFunc     Func values_ASCII()         Local $calc_total = 0         $aInfo = _ImageGetInfo($file)         $i_width = _ImageGetParam($aInfo, "Width")         $i_height =  _ImageGetParam($aInfo, "Height")         $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreatePic($file,0,0,$i_width,$i_height)         $pr_height = WinGetPos($image)         $progress = Guicreate("Progress",130,60,-1,$pr_height[1]-65,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreateLabel("Reading:",10,10,100,20)         $pixel_atm = GUICtrlCreateLabel("",60,10,150,20)         GUICtrlCreateLabel("/",90,10,100,20)         $pixel_total = GUICtrlCreateLabel("",100,10,100,20)         $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH)         $procent = GUICtrlCreateLabel("100",50,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlCreateLabel("%",70,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUISetState(@SW_hide,$main)         GUISetState(@SW_Show,$image)         GUISetState(@SW_Show,$progress)         $pixel_total_width = GUICtrlRead($width_test)         $pixel_total_height = GUICtrlRead($height_test)         $calc_1 = round($pixel_total_width/($procent_pixels-1))         $calc_2 = round($pixel_total_height/$procent_pixels)         $calc_1_2 = $calc_1 * $calc_2         GUICtrlSetData($pixel_total,$calc_1_2)         $value_progress = 100/$calc_1_2         $info = WinGetPos($image)         $read_procent = GUICtrlRead($slider_procent)         $value = 100 / $read_procent         $procent_pixels = Round($value)         if $procent_pixels = 1 Then             $procent_pixels = 2         EndIf         $pixel_total_width = GUICtrlRead($width_test)         $pixel_total_height = GUICtrlRead($height_test)         $calc_1 = round($pixel_total_width/($procent_pixels-1))         $calc_2 = round($pixel_total_height/$procent_pixels)         $calc_1_2 = $calc_1 * $calc_2         GUICtrlSetData($pixel_total,$calc_1_2)         $value_progress = 100/$calc_1_2         $font_color = GUICtrlRead($font_color_ASCII)         $bg_color = GUICtrlRead($bg_color_ASCII)         $size_char = GUICtrlRead($char_size_ASCII)     Select         case $size_char = "Smallest"             $size_ASCII = "-6"         case $size_char = "Small"             $size_ASCII = "-3"         case $size_char = "Normal"             $size_ASCII = "1"         case $size_char = "Large"             $size_ASCII = "4"         case $size_char = "Largest"             $size_ASCII = "6"     EndSelect     if GUICtrlRead($invert) = 1 Then         convert_ASCII_invert()     Else         convert_ASCII()     EndIf EndFunc       Func convert_color_random()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & Hex($color,6) & '">' & StringMid($waardes,$char,1) & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next                FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm",$contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit EndFunc Func convert_color_Sequence()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $color & '">' & $show & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit    EndFunc     Func convert_grayscale_random()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & StringMid($waardes,$char,1) & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @CRLF)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit    EndFunc     Func convert_grayscale_Sequence()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & $show & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit EndFunc func convert_ASCII()        Local $pixel        $begin = TimerInit()        Dim $replace_characters[17]        $replace_characters[0] = "#"        $replace_characters[1] = "W"        $replace_characters[2] = "M"        $replace_characters[3] = "B"        $replace_characters[4] = "R"        $replace_characters[5] = "X"        $replace_characters[6] = "V"        $replace_characters[7] = "Y"        $replace_characters[8] = "I"        $replace_characters[9] = "t"        $replace_characters[10] = "i"        $replace_characters[11] = "+"        $replace_characters[12] = "="        $replace_characters[13] = ";"        $replace_characters[14] = ":"        $replace_characters[15] = ","        $replace_characters[16] = "."       FileDelete(@ScriptDir & "\html.htm")       FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)       FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf &'<table width="80%"><tr><td> <table align="center" cellpadding="10" > <tr bgcolor="' & $bg_color & '"> <td> <font color="' & $font_color & '" size="' & $size_ASCII & '"><pre>' &@crlf)       For $i = 1 to $i_height step +$procent_pixels               For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] +$i)                     $var = Hex($color, 6)                     $gray_1 = dec(StringLeft($var,2))                     $gray_2 = dec(StringMid($var,3,2))                     $gray_3 = dec(StringRight($var,2))                     $brightness = $gray_1+$gray_2+$gray_3                     $replace_character_id = Round($brightness/50) +1                     FileWrite(@ScriptDir & "\html.htm",$replace_characters[$replace_character_id])                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)               Next        FileWrite(@ScriptDir & "\html.htm",@CRLF)       Next       GUISetState(@SW_HIDE,$image)       FileWrite(@ScriptDir & "\html.htm", "</pre></font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)       $dif = TimerDiff($begin)       Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")       ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")       Exit EndFunc   func convert_ASCII_invert()        Local $pixel        $begin = TimerInit()        Dim $replace_characters[17]        $replace_characters[0] = "."        $replace_characters[1] = ","        $replace_characters[2] = ":"        $replace_characters[3] = ";"        $replace_characters[4] = "="        $replace_characters[5] = "+"        $replace_characters[6] = "i"        $replace_characters[7] = "t"        $replace_characters[8] = "I"        $replace_characters[9] = "Y"        $replace_characters[10] = "V"        $replace_characters[11] = "X"        $replace_characters[12] = "R"        $replace_characters[13] = "B"        $replace_characters[14] = "M"        $replace_characters[15] = "W"        $replace_characters[16] = "#"       FileDelete(@ScriptDir & "\html.htm")       FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)       FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf &'<table width="80%"><tr><td> <table align="center" cellpadding="10" > <tr bgcolor="' & $bg_color & '"> <td> <font color="' & $font_color & '" size="' & $size_ASCII & '"><pre>' &@crlf)       For $i = 1 to $i_height step +$procent_pixels               For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] +$i)                     $var = Hex($color, 6)                     $gray_1 = dec(StringLeft($var,2))                     $gray_2 = dec(StringMid($var,3,2))                     $gray_3 = dec(StringRight($var,2))                     $brightness = $gray_1+$gray_2+$gray_3                     $replace_character_id = Round($brightness/50) +1                     FileWrite(@ScriptDir & "\html.htm",$replace_characters[$replace_character_id])                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)               Next        FileWrite(@ScriptDir & "\html.htm",@CRLF)       Next       GUISetState(@SW_HIDE,$image)       FileWrite(@ScriptDir & "\html.htm", "</pre></font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)       $dif = TimerDiff($begin)       Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")       ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")       Exit EndFunc
_linenums:0'>
AutoIt         
#include <File.au3> #include <Guiconstants.au3> #include <image_get_info.au3> Global $i_height,$i_width,$waardes,$total,$info,$image,$contrast_value,$contrast_value_end,$size Global $procent_pixels,$pixel_atm,$value_progress,$progressbar,$progress,$progress_count,$procent Global $bg_color,$font_color,$size_ASCII $Main = GUICreate("Image to Text", 629, 363, 193, 115) GUICtrlCreateGroup("Preview Image", 8, 8, 305, 345) $Picca = GUICtrlCreatePic("", 16, 32, 225, 209) $slider_procent = GUICtrlCreateSlider (25,256,200,20) GUICtrlSetState(-1,$GUI_DISABLE) $slider_procent_text = GUICtrlCreateLabel("",230,256,50,20) $Label9 = GUICtrlCreateLabel("% of pixels", 255, 255, 50, 17) $width_test = GUICtrlCreateLabel(" ", 36, 286, 30, 17) $Label2 = GUICtrlCreateLabel("x", 64, 286, 9, 17) $height_test = GUICtrlCreateLabel(" ", 80, 286, 30, 17) $file_size = GUICtrlCreateLabel(" ", 55, 310, 30, 17) $Label5 = GUICtrlCreateLabel("Kb", 75, 310, 17, 17) $Label6 = GUICtrlCreateLabel("Pixels", 128, 286, 31, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $tab_text =GUICtrlCreateTab (320,8, 305,345) $color_grayscale = GUICtrlCreateTabitem("Color / Grayscale") $browse = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters:", 328, 72, 257, 80) $characters = GUICtrlCreateInput("Characters", 336, 92, 100, 21) $char_size = GUICtrlCreateCombo("Smallest", 450, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") $random = GUICtrlCreateRadio("Random", 336, 120, 105, 25) GUICtrlSetState($Random, $GUI_CHECKED) $Sequence = GUICtrlCreateRadio("Sequence", 456, 120, 121, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Color:", 328, 160, 257, 95) $color = GUICtrlCreateRadio("Color", 336, 176, 97, 25) $grayscale  = GUICtrlCreateRadio("Grayscale", 456, 176, 97, 25) GUICtrlSetState($color, $GUI_CHECKED) $Label7 = GUICtrlCreateLabel("Background:",336, 207, 193, 25) $bg_color = GUICtrlCreateCombo("BLACK", 336, 225, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Contrast:", 328, 260, 257, 49) $high = GUICtrlCreateRadio("High", 336, 276, 113, 25) $low = GUICtrlCreateRadio("Low", 456, 276, 113, 25) GUICtrlSetState($low, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $ok_button = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) $ASCII = GUICtrlCreateTabitem("ASCII") $browse_ASCII = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters Size:", 328, 72, 257, 50) $char_size_ASCII = GUICtrlCreateCombo("Smallest", 336, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Font/Background color:", 328, 130, 257, 120) $Label7_ASCII = GUICtrlCreateLabel("Font color:",336, 150, 193, 25) $font_color_ASCII = GUICtrlCreateCombo("BLACK", 336, 168, 193, 25) GUICtrlSetData(-1,"WHITE","WHITE") $Label7_ASCII = GUICtrlCreateLabel("Background:",336, 197, 193, 25) $bg_color_ASCII = GUICtrlCreateCombo("BLACK", 336, 215, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) $invert = GUICtrlCreateCheckbox ("Invert", 336, 260, 120, 20) $ok_button_ASCII = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) GUISetState(@SW_SHOW) While 1     $msg = GUIGetMsg()     Select     Case $msg = $GUI_EVENT_CLOSE         Exit     Case $msg = $browse         $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)")         $aInfo_test = _ImageGetInfo($file)         GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width"))         GUICtrlSetData($height_test, _ImageGetParam($aInfo_test, "Height"))         Guictrlsetdata($file_size, int(FileGetSize($file)/1000))         GUICtrlSetImage($picca,$file)         GUICtrlSetState($slider_procent,$GUI_ENABLE)         GUICtrlSetData($slider_procent,25)     case $msg = $browse_ASCII         $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)")         $aInfo_test = _ImageGetInfo($file)         GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width"))         GUICtrlSetData($height_test,_ImageGetParam($aInfo_test, "Height"))         Guictrlsetdata($file_size, int(FileGetSize($file)/1000))         GUICtrlSetImage($picca,$file)         GUICtrlSetState($slider_procent,$GUI_ENABLE)         GUICtrlSetData($slider_procent,25)     Case $msg = $ok_button         values()     case $msg = $ok_button_ASCII         values_ASCII()     EndSelect     $read_procent = GUICtrlRead($slider_procent)     GUICtrlSetData($slider_procent_text,$read_procent)     Sleep(25) WEnd func values()         Local $calc_total = 0         $aInfo = _ImageGetInfo($file)         $i_width = _ImageGetParam($aInfo, "Width")         $i_height =  _ImageGetParam($aInfo, "Height")         $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreatePic($file,0,0,$i_width,$i_height)         $pr_height = WinGetPos($image)         $progress = Guicreate("Progress",130,60,-1,$pr_height[1]-65,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreateLabel("Reading:",10,10,100,20)         $pixel_atm = GUICtrlCreateLabel("",60,10,150,20)         GUICtrlCreateLabel("/",90,10,100,20)         $pixel_total = GUICtrlCreateLabel("",100,10,100,20)         $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH)         $procent = GUICtrlCreateLabel("100",50,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlCreateLabel("%",70,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUISetState(@SW_hide,$main)         GUISetState(@SW_Show,$image)         GUISetState(@SW_Show,$progress)         $waardes = GUICtrlRead($characters)         $total = Int(StringLen($waardes))         $info = WinGetPos($image)         $read_procent = GUICtrlRead($slider_procent)         $value = 100 / $read_procent         $procent_pixels = Round($value)         if $procent_pixels = 1 Then             $procent_pixels = 2         EndIf         $pixel_total_width = GUICtrlRead($width_test)         $pixel_total_height = GUICtrlRead($height_test)         $calc_1 = round($pixel_total_width/($procent_pixels-1))         $calc_2 = round($pixel_total_height/$procent_pixels)         $calc_1_2 = $calc_1 * $calc_2         GUICtrlSetData($pixel_total,$calc_1_2)         $value_progress = 100/$calc_1_2         $r_checked = GUICtrlRead($random)         $l_checked = GuiCtrlRead($low)         $c_checked = GUICtrlRead($color)         $size_char = GUICtrlRead($char_size)         Select         case $size_char = "Smallest"             $size = "-6"         case $size_char = "Small"             $size = "-3"         case $size_char = "Normal"             $size = "1"         case $size_char = "Large"             $size = "4"         case $size_char = "Largest"             $size = "6"         EndSelect         Select         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_color_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_color_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_color_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_color_Sequence()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_grayscale_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_grayscale_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = "<pre>"             $contrast_value_end = "</pre>"             convert_grayscale_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED             $contrast_value = ""             $contrast_value_end = ""             convert_grayscale_Sequence()        EndSelect EndFunc     Func values_ASCII()         Local $calc_total = 0         $aInfo = _ImageGetInfo($file)         $i_width = _ImageGetParam($aInfo, "Width")         $i_height =  _ImageGetParam($aInfo, "Height")         $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreatePic($file,0,0,$i_width,$i_height)         $pr_height = WinGetPos($image)         $progress = Guicreate("Progress",130,60,-1,$pr_height[1]-65,$WS_POPUP,$WS_EX_TOPMOST)         GUICtrlCreateLabel("Reading:",10,10,100,20)         $pixel_atm = GUICtrlCreateLabel("",60,10,150,20)         GUICtrlCreateLabel("/",90,10,100,20)         $pixel_total = GUICtrlCreateLabel("",100,10,100,20)         $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH)         $procent = GUICtrlCreateLabel("100",50,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUICtrlCreateLabel("%",70,33,30,20)         GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)         GUISetState(@SW_hide,$main)         GUISetState(@SW_Show,$image)         GUISetState(@SW_Show,$progress)         $pixel_total_width = GUICtrlRead($width_test)         $pixel_total_height = GUICtrlRead($height_test)         $calc_1 = round($pixel_total_width/($procent_pixels-1))         $calc_2 = round($pixel_total_height/$procent_pixels)         $calc_1_2 = $calc_1 * $calc_2         GUICtrlSetData($pixel_total,$calc_1_2)         $value_progress = 100/$calc_1_2         $info = WinGetPos($image)         $read_procent = GUICtrlRead($slider_procent)         $value = 100 / $read_procent         $procent_pixels = Round($value)         if $procent_pixels = 1 Then             $procent_pixels = 2         EndIf         $pixel_total_width = GUICtrlRead($width_test)         $pixel_total_height = GUICtrlRead($height_test)         $calc_1 = round($pixel_total_width/($procent_pixels-1))         $calc_2 = round($pixel_total_height/$procent_pixels)         $calc_1_2 = $calc_1 * $calc_2         GUICtrlSetData($pixel_total,$calc_1_2)         $value_progress = 100/$calc_1_2         $font_color = GUICtrlRead($font_color_ASCII)         $bg_color = GUICtrlRead($bg_color_ASCII)         $size_char = GUICtrlRead($char_size_ASCII)     Select         case $size_char = "Smallest"             $size_ASCII = "-6"         case $size_char = "Small"             $size_ASCII = "-3"         case $size_char = "Normal"             $size_ASCII = "1"         case $size_char = "Large"             $size_ASCII = "4"         case $size_char = "Largest"             $size_ASCII = "6"     EndSelect     if GUICtrlRead($invert) = 1 Then         convert_ASCII_invert()     Else         convert_ASCII()     EndIf EndFunc       Func convert_color_random()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & Hex($color,6) & '">' & StringMid($waardes,$char,1) & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next                FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm",$contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit EndFunc Func convert_color_Sequence()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $color & '">' & $show & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit    EndFunc     Func convert_grayscale_random()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & StringMid($waardes,$char,1) & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @CRLF)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit    EndFunc     Func convert_grayscale_Sequence()        Local $pixel        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & $show & "</font>")                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        GUISetState(@SW_HIDE,$progress)        Exit EndFunc func convert_ASCII()        Local $pixel        $begin = TimerInit()        Dim $replace_characters[17]        $replace_characters[0] = "#"        $replace_characters[1] = "W"        $replace_characters[2] = "M"        $replace_characters[3] = "B"        $replace_characters[4] = "R"        $replace_characters[5] = "X"        $replace_characters[6] = "V"        $replace_characters[7] = "Y"        $replace_characters[8] = "I"        $replace_characters[9] = "t"        $replace_characters[10] = "i"        $replace_characters[11] = "+"        $replace_characters[12] = "="        $replace_characters[13] = ";"        $replace_characters[14] = ":"        $replace_characters[15] = ","        $replace_characters[16] = "."       FileDelete(@ScriptDir & "\html.htm")       FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)       FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf &'<table width="80%"><tr><td> <table align="center" cellpadding="10" > <tr bgcolor="' & $bg_color & '"> <td> <font color="' & $font_color & '" size="' & $size_ASCII & '"><pre>' &@crlf)       For $i = 1 to $i_height step +$procent_pixels               For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] +$i)                     $var = Hex($color, 6)                     $gray_1 = dec(StringLeft($var,2))                     $gray_2 = dec(StringMid($var,3,2))                     $gray_3 = dec(StringRight($var,2))                     $brightness = $gray_1+$gray_2+$gray_3                     $replace_character_id = Round($brightness/50) +1                     FileWrite(@ScriptDir & "\html.htm",$replace_characters[$replace_character_id])                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)               Next        FileWrite(@ScriptDir & "\html.htm",@CRLF)       Next       GUISetState(@SW_HIDE,$image)       FileWrite(@ScriptDir & "\html.htm", "</pre></font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)       $dif = TimerDiff($begin)       Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")       ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")       Exit EndFunc   func convert_ASCII_invert()        Local $pixel        $begin = TimerInit()        Dim $replace_characters[17]        $replace_characters[0] = "."        $replace_characters[1] = ","        $replace_characters[2] = ":"        $replace_characters[3] = ";"        $replace_characters[4] = "="        $replace_characters[5] = "+"        $replace_characters[6] = "i"        $replace_characters[7] = "t"        $replace_characters[8] = "I"        $replace_characters[9] = "Y"        $replace_characters[10] = "V"        $replace_characters[11] = "X"        $replace_characters[12] = "R"        $replace_characters[13] = "B"        $replace_characters[14] = "M"        $replace_characters[15] = "W"        $replace_characters[16] = "#"       FileDelete(@ScriptDir & "\html.htm")       FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)       FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf &'<table width="80%"><tr><td> <table align="center" cellpadding="10" > <tr bgcolor="' & $bg_color & '"> <td> <font color="' & $font_color & '" size="' & $size_ASCII & '"><pre>' &@crlf)       For $i = 1 to $i_height step +$procent_pixels               For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] +$i)                     $var = Hex($color, 6)                     $gray_1 = dec(StringLeft($var,2))                     $gray_2 = dec(StringMid($var,3,2))                     $gray_3 = dec(StringRight($var,2))                     $brightness = $gray_1+$gray_2+$gray_3                     $replace_character_id = Round($brightness/50) +1                     FileWrite(@ScriptDir & "\html.htm",$replace_characters[$replace_character_id])                     $pixel = $pixel + 1                     GUICtrlSetData($pixel_atm,$pixel)                     $progress_count = $progress_count + $value_progress                     $progress_count_rounded = Round($progress_count)                     GUICtrlSetData($progressbar,$progress_count_rounded)                     GUICtrlSetData($procent,$progress_count_rounded)               Next        FileWrite(@ScriptDir & "\html.htm",@CRLF)       Next       GUISetState(@SW_HIDE,$image)       FileWrite(@ScriptDir & "\html.htm", "</pre></font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)       $dif = TimerDiff($begin)       Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")       ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")       Exit EndFunc

*Edit: Some pic-examples:
Color:
Posted Image

Grayscale:
Posted Image


First script: 100 downloads+ :)

Attached Files


Edited by NeoFoX, 11 January 2007 - 09:02 AM.

--- The Neo and Only --- --Projects---Image to Text converterText to ASCII converter








#2 XxXFaNtA

XxXFaNtA

    Adventurer

  • Active Members
  • PipPip
  • 128 posts

Posted 08 January 2007 - 07:27 PM

Wow really nice :P

More of these image-scripts please :D
/

Posted Image


#3 BALA

BALA

    I'm a pirate! :)

  • Active Members
  • PipPipPipPipPipPip
  • 504 posts

Posted 08 January 2007 - 07:45 PM

That's incredible, it beats some of the ones you have to pay for. :P
BA-LAhttp://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

#4 smstroble

smstroble

    Prodigy

  • Active Members
  • PipPipPip
  • 191 posts

Posted 08 January 2007 - 08:32 PM

Wow... This is incredible, very nice "first official script"! I look forward to your future work.
MUHAHAHAHAHA

#5 NeoFoX

NeoFoX

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 09 January 2007 - 08:59 AM

*Edited: Font-size option...

See first Post :P

Neo

--- The Neo and Only --- --Projects---Image to Text converterText to ASCII converter


#6 jaenster

jaenster

    There is no spoon.

  • Active Members
  • PipPipPipPipPipPip
  • 670 posts

Posted 09 January 2007 - 02:02 PM

Wow... This is incredible !!!!!! WOW !!!
-jaenster

#7 Josbe

Josbe

    Infrequent ghost ☺

  • Active Members
  • PipPipPipPipPipPip
  • 1,585 posts

Posted 09 January 2007 - 02:23 PM

@NeoFoX: Nice script. Thanks for sharing.
I like the ASCII Art.

#8 NeoFoX

NeoFoX

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 09 January 2007 - 02:25 PM

*Edited: Now you can chose how much % of the image you want to convert
(100% is slow... but will give you a, almost perfect and nice image/text :D)

See first post :)

Neo

ps. Thanks all for the comments :D

Edited by NeoFoX, 09 January 2007 - 02:28 PM.

--- The Neo and Only --- --Projects---Image to Text converterText to ASCII converter


#9 Manadar

Manadar

    Taking a REST.

  • MVPs
  • 10,714 posts

Posted 09 January 2007 - 03:05 PM

Amazing, you have a lot of knowledge about images.

#10 AzKay

AzKay

    MY LOVE FOR YOU IS LIKE A TRUCK, BERSERKERRRRRRR

  • Active Members
  • PipPipPipPipPipPip
  • 1,971 posts

Posted 09 January 2007 - 03:58 PM

Plain Text         
#include <File.au3> #include <Guiconstants.au3> #include <image_get_info.au3> Global $i_height,$i_width,$waardes,$total,$info,$image,$contrast_value,$contrast_value_end,$size, $progress Global $procent_pixels $Main = GUICreate("Image to Text", 629, 363, 193, 115) GUICtrlCreateGroup("Preview Image", 8, 8, 305, 345) $Picca = GUICtrlCreatePic("", 16, 32, 225, 209) $slider_procent = GUICtrlCreateSlider (25,256,200,20) GUICtrlSetState(-1,$GUI_DISABLE) $slider_procent_text = GUICtrlCreateLabel("",230,256,50,20) $Label9 = GUICtrlCreateLabel("% of pixels", 255, 255, 50, 17) $width_test = GUICtrlCreateLabel(" ", 36, 286, 30, 17) $Label2 = GUICtrlCreateLabel("x", 64, 286, 9, 17) $height_test = GUICtrlCreateLabel(" ", 80, 286, 30, 17) $file_size = GUICtrlCreateLabel(" ", 55, 310, 30, 17) $Label5 = GUICtrlCreateLabel("Kb", 72, 310, 17, 17) $Label6 = GUICtrlCreateLabel("Pixels", 128, 286, 31, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Options", 320, 8, 305, 345) $browse = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters:", 328, 72, 257, 80) $characters = GUICtrlCreateInput("Characters", 336, 92, 100, 21) $char_size = GUICtrlCreateCombo("Smallest", 450, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") $random = GUICtrlCreateRadio("Random", 336, 120, 105, 25) GUICtrlSetState($Random, $GUI_CHECKED) $Sequence = GUICtrlCreateRadio("Sequence", 456, 120, 121, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Color:", 328, 160, 257, 95) $color = GUICtrlCreateRadio("Color", 336, 176, 97, 25) $grayscale  = GUICtrlCreateRadio("Grayscale", 456, 176, 97, 25) GUICtrlSetState($color, $GUI_CHECKED) $Label7 = GUICtrlCreateLabel("Background:",336, 207, 193, 25) $bg_color = GUICtrlCreateCombo("BLACK", 336, 225, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Contrast:", 328, 260, 257, 49) $high = GUICtrlCreateRadio("High", 336, 276, 113, 25) $low = GUICtrlCreateRadio("Low", 456, 276, 113, 25) GUICtrlSetState($low, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $ok_button = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1        $msg = GUIGetMsg()        Select        Case $msg = $GUI_EVENT_CLOSE                Exit        Case $msg = $browse                $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)")                $aInfo_test = _ImageGetInfo($file)                GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width"))                GUICtrlSetData($height_test, _ImageGetParam($aInfo_test, "Height"))                Guictrlsetdata($file_size, int(FileGetSize($file)/1000))                GUICtrlSetImage($picca,$file)                GUICtrlSetState($slider_procent,$GUI_ENABLE)                GUICtrlSetData($slider_procent,25)        Case $msg = $ok_button                values()        EndSelect        $read_procent = GUICtrlRead($slider_procent)        GUICtrlSetData($slider_procent_text,$read_procent)        Sleep(10) WEnd func values()        $aInfo = _ImageGetInfo($file)        $i_width = _ImageGetParam($aInfo, "Width")        $i_height =  _ImageGetParam($aInfo, "Height")        ;$image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)        ;GUICtrlCreatePic($file,0,0,$i_width,$i_height)        $image = GUICreate("Progress", 350, 22, -1, -1)        $progress = GUICtrlCreateProgress(1, 1, 345, 19)        GUISetState(@SW_hide,$main)        GUISetState(@SW_Show,$image)        $waardes = GUICtrlRead($characters)        $total = Int(StringLen($waardes))        $info = WinGetPos($image)        $read_procent = GUICtrlRead($slider_procent)        $value = 100 / $read_procent        $procent_pixels = Round($value)        if $procent_pixels = 1 Then            $procent_pixels = 2        EndIf        $r_checked = GUICtrlRead($random)        $l_checked = GuiCtrlRead($low)        $c_checked = GUICtrlRead($color)        $size_char = GUICtrlRead($char_size)        Select         case $size_char = "smallest"            $size = "-6"         case $size_char = "small"            $size = "-3"         case $size_char = "normal"            $size = "1"         case $size_char = "large"            $size = "4"         case $size_char = "largest"            $size = "6"         EndSelect        Select         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_color_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_color_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_color_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_color_Sequence()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_grayscale_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_grayscale_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_grayscale_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_grayscale_Sequence()        EndSelect EndFunc     Func convert_color_random()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td>' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     FileWrite(@ScriptDir & "\html.htm",'<font size="-6" color="#' & Hex($color,6) & '">' & StringMid($waardes,$char,1) & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next                FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm",$contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit EndFunc Func convert_color_Sequence()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $color & '">' & $show & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit    EndFunc     Func convert_grayscale_random()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & StringMid($waardes,$char,1) & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @CRLF)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit    EndFunc     Func convert_grayscale_Sequence()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & $show & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit EndFunc

_linenums:0'>
AutoIt         
#include <File.au3> #include <Guiconstants.au3> #include <image_get_info.au3> Global $i_height,$i_width,$waardes,$total,$info,$image,$contrast_value,$contrast_value_end,$size, $progress Global $procent_pixels $Main = GUICreate("Image to Text", 629, 363, 193, 115) GUICtrlCreateGroup("Preview Image", 8, 8, 305, 345) $Picca = GUICtrlCreatePic("", 16, 32, 225, 209) $slider_procent = GUICtrlCreateSlider (25,256,200,20) GUICtrlSetState(-1,$GUI_DISABLE) $slider_procent_text = GUICtrlCreateLabel("",230,256,50,20) $Label9 = GUICtrlCreateLabel("% of pixels", 255, 255, 50, 17) $width_test = GUICtrlCreateLabel(" ", 36, 286, 30, 17) $Label2 = GUICtrlCreateLabel("x", 64, 286, 9, 17) $height_test = GUICtrlCreateLabel(" ", 80, 286, 30, 17) $file_size = GUICtrlCreateLabel(" ", 55, 310, 30, 17) $Label5 = GUICtrlCreateLabel("Kb", 72, 310, 17, 17) $Label6 = GUICtrlCreateLabel("Pixels", 128, 286, 31, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Options", 320, 8, 305, 345) $browse = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters:", 328, 72, 257, 80) $characters = GUICtrlCreateInput("Characters", 336, 92, 100, 21) $char_size = GUICtrlCreateCombo("Smallest", 450, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") $random = GUICtrlCreateRadio("Random", 336, 120, 105, 25) GUICtrlSetState($Random, $GUI_CHECKED) $Sequence = GUICtrlCreateRadio("Sequence", 456, 120, 121, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Color:", 328, 160, 257, 95) $color = GUICtrlCreateRadio("Color", 336, 176, 97, 25) $grayscale  = GUICtrlCreateRadio("Grayscale", 456, 176, 97, 25) GUICtrlSetState($color, $GUI_CHECKED) $Label7 = GUICtrlCreateLabel("Background:",336, 207, 193, 25) $bg_color = GUICtrlCreateCombo("BLACK", 336, 225, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Contrast:", 328, 260, 257, 49) $high = GUICtrlCreateRadio("High", 336, 276, 113, 25) $low = GUICtrlCreateRadio("Low", 456, 276, 113, 25) GUICtrlSetState($low, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $ok_button = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1        $msg = GUIGetMsg()        Select        Case $msg = $GUI_EVENT_CLOSE                Exit        Case $msg = $browse                $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)")                $aInfo_test = _ImageGetInfo($file)                GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width"))                GUICtrlSetData($height_test, _ImageGetParam($aInfo_test, "Height"))                Guictrlsetdata($file_size, int(FileGetSize($file)/1000))                GUICtrlSetImage($picca,$file)                GUICtrlSetState($slider_procent,$GUI_ENABLE)                GUICtrlSetData($slider_procent,25)        Case $msg = $ok_button                values()        EndSelect        $read_procent = GUICtrlRead($slider_procent)        GUICtrlSetData($slider_procent_text,$read_procent)        Sleep(10) WEnd func values()        $aInfo = _ImageGetInfo($file)        $i_width = _ImageGetParam($aInfo, "Width")        $i_height =  _ImageGetParam($aInfo, "Height")        ;$image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST)        ;GUICtrlCreatePic($file,0,0,$i_width,$i_height)        $image = GUICreate("Progress", 350, 22, -1, -1)        $progress = GUICtrlCreateProgress(1, 1, 345, 19)        GUISetState(@SW_hide,$main)        GUISetState(@SW_Show,$image)        $waardes = GUICtrlRead($characters)        $total = Int(StringLen($waardes))        $info = WinGetPos($image)        $read_procent = GUICtrlRead($slider_procent)        $value = 100 / $read_procent        $procent_pixels = Round($value)        if $procent_pixels = 1 Then            $procent_pixels = 2        EndIf        $r_checked = GUICtrlRead($random)        $l_checked = GuiCtrlRead($low)        $c_checked = GUICtrlRead($color)        $size_char = GUICtrlRead($char_size)        Select         case $size_char = "smallest"            $size = "-6"         case $size_char = "small"            $size = "-3"         case $size_char = "normal"            $size = "1"         case $size_char = "large"            $size = "4"         case $size_char = "largest"            $size = "6"         EndSelect        Select         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_color_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_color_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_color_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_color_Sequence()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_grayscale_random()         case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_grayscale_random()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = "<pre>"                $contrast_value_end = "</pre>"                convert_grayscale_Sequence()         case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED                $contrast_value = ""                $contrast_value_end = ""                convert_grayscale_Sequence()        EndSelect EndFunc     Func convert_color_random()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td>' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     FileWrite(@ScriptDir & "\html.htm",'<font size="-6" color="#' & Hex($color,6) & '">' & StringMid($waardes,$char,1) & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next                FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm",$contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit EndFunc Func convert_color_Sequence()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $color & '">' & $show & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit    EndFunc     Func convert_grayscale_random()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $char = Random(1,$total+1)                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & StringMid($waardes,$char,1) & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @CRLF)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit    EndFunc     Func convert_grayscale_Sequence()        $begin = TimerInit()        FileDelete(@ScriptDir & "\html.htm")        FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf)        FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf)        For $i = 1 to $i_height step +$procent_pixels                For $x = 1 to $i_width step +($procent_pixels-1)                     $color = PixelGetColor($info[0] + $x , $info[1] + $i)                     $show = $waardes                     $var = Hex($color, 6)                     $gray_1 = int(dec(StringLeft($var,2))*0.3)                     $gray_2 = int(dec(StringMid($var,3,2))*0.59)                     $gray_3 = int(dec(StringRight($var,2))*0.11)                     $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1)                     FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & $show & "</font>")                     GUICtrlSetData($progress, $i / $i_height * 100)                Next         FileWrite(@ScriptDir & "\html.htm","<br>")        Next        GUISetState(@SW_HIDE,$image)        FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf)        $dif = TimerDiff($begin)        Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>")        ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open")        Exit EndFunc

Added a progress bar instead of the image :3
Great Work :)

EDIT::
That didnt work right xD.
Was that image needed? I was in a hurry, so I didnt check. =P
You might wanna tweak it, It uses the GUI's title bar as the image, lawl.

Edited by AzKay, 09 January 2007 - 04:02 PM.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

#11 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 09 January 2007 - 05:55 PM

This is a great script. Well done!
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#12 walle

walle

    Polymath

  • Active Members
  • PipPipPipPip
  • 234 posts

Posted 09 January 2007 - 08:21 PM

Gets a error, anyway, great work!

Line 157

ShellExecute(@Scriptdir & "\html.htm","",@ScriptDir,"Open") ^Error


#13 AzKay

AzKay

    MY LOVE FOR YOU IS LIKE A TRUCK, BERSERKERRRRRRR

  • Active Members
  • PipPipPipPipPipPip
  • 1,971 posts

Posted 09 January 2007 - 10:09 PM

Saying "Great work!", When its not working for you, thus you havnt tryed it out. Its kinda redundant to say "Great work!" xD
Anyways, Make sure your using the latest BETA :3
# MY LOVE FOR YOU... IS LIKE A TRUCK- #

#14 NeoFoX

NeoFoX

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 10 January 2007 - 07:28 AM

@Walle: If the shellexecute isn't working :) you'll always have the .htm file in your Scriptdir, so you can open it manually... And indeed it's made with beta

Neo

--- The Neo and Only --- --Projects---Image to Text converterText to ASCII converter


#15 NeoFoX

NeoFoX

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 10 January 2007 - 09:26 AM

*Edited: Progressbar at the top of the picture...

See first post :)

Neo

--- The Neo and Only --- --Projects---Image to Text converterText to ASCII converter


#16 masvil

masvil

    Adventurer

  • Active Members
  • PipPip
  • 143 posts

Posted 10 January 2007 - 10:42 PM

Impressive. Congratulation.

#17 Achilles

Achilles

    Achilles == Ichigo

  • Active Members
  • PipPipPipPipPipPip
  • 2,897 posts

Posted 11 January 2007 - 04:21 AM

Well, after a day of scripting my result:


Must of been quite some day! Great program!

#18 NeoFoX

NeoFoX

    Adventurer

  • Active Members
  • PipPip
  • 141 posts

Posted 11 January 2007 - 09:18 AM

Well.. what would I say :)

*NEW update* Added new Functions

Try them...

Neo

--- The Neo and Only --- --Projects---Image to Text converterText to ASCII converter


#19 Zephir

Zephir

    Prodigy

  • Active Members
  • PipPipPip
  • 184 posts

Posted 12 January 2007 - 09:41 AM

awesome script, i love it :)
keep up the god work

#20 phantom

phantom

    Seeker

  • Active Members
  • 31 posts

Posted 12 January 2007 - 12:22 PM

This is very nice :D but how do copy the image onto my computer in a different format rather than .html :)
i tried just changing what it saves the file as from .htm to .jpg but it never showed the pic when i opened it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users