Jump to content

Image to Text


NeoFoX
 Share

Recommended Posts

Well.. I made it writing to .htm because I haven't found a solution/way to create or update *.jpg/*.gif or any other pic vairable yet..

So sorry about that :)

(You could get a PrintScrn of your converted image and than past it to some kind of Pic-programmer and safe it manually...)

Neo

[center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center]

Link to comment
Share on other sites

  • Replies 57
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Neo, how'd you manage to get the numbers smaller and closer together (vertically) than mine is outputting to the html files :| Or is it just when you made it the image you shrank it down? Also, any help on shrinking the space between lines? It stretches all my pics vertically :)

Otherwise great work!

Link to comment
Share on other sites

  • 1 month later...

Wow, this is really cool. For some reasons I'm having some weird extra "garbage" added to the output though:

source: Posted Image result: Posted Image

Notice the extra white line on the right hand side? I'm getting something similar with several images I've tried. Any idea what could be wrong? I'm using AutoIt 3.2.2.0.

Link to comment
Share on other sites

NeoFoX

Wow! it's realy great script... thanx!

but when you open it, then the precent label is always “jumping”, try put this as 3 lines at the end of main loop:

$read_procent = GUICtrlRead($slider_procent)

If GUICtrlRead($slider_procent) <> GUICtrlRead($slider_procent_text) Then GUICtrlSetData($slider_procent_text,$read_procent)

Sleep(25)

And also, if you open a big picture, then when you start to convert it splash on all the screen, and i can do nothing while it converted, its not good, maby some how show the converting process in background, or do it like a preview, or some option to hide this process, couse in some cases it can take a long time, and you don't want to look at the image all of that time :whistle: , don't you?.

Sorry for my english :"> .

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Nice work.

I started someting similar. Here I scanned a simple pic and put it in text and rotated making 4 graphics out of one and in the gui made it to rotate.

http://www.autoitscript.com/forum/index.php?showtopic=41571

My comments:

-- should save last folder browsed to .ini

-- should keep the GUI open.

-- name output .htm file according to the file you selected. If it already exists add a number to it or something.. like:

$fil = ""
$ext = ".htm"
$c = 0
While FileExists($folder & $name & $fil & $ext)
    $fil = "("& $c &")"
    $c += 1
WEnd
Link to comment
Share on other sites

  • 4 months later...

I'm getting the same as dandymcgee.

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.
Link to comment
Share on other sites

  • 2 weeks later...

Darn, I was just going to post a similar (but not as full-featured) script to this and figured I'd better search to see if it had been done...Apparently it's been done quite well, eh? :)

However, though the interface is very nice and the scripting looks great, I'm not getting any output...that is to say, the html.htm file it creates in @ScriptDir only displays the text "Time took to convert: 0". Looking at the source, I see

<html>
<body>
<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="BLACK"> <td> <font size="-3"><pre>
</pre>
</font>
</td></tr></table></td></tr></table>

<font face="arial"> Time took to convert: <b>0</b> sec.</font>
</body>
</html>
(there's nothing between <pre> and </pre> but a line break...I assume this is where the characters should be...in short, I'm getting the same error as the previous few posts)

When I ran your script, I browsed for a picture, left everything else at default, and clicked "Convert". I get the same output whether I'm on the Color / Grayscale tab or the ASCII tab. I don't think there should be any other steps - any idea what's wrong?

Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

Anyway, failing to solve the non-functionality myself, and guessing that the problem is somewhere within LazyCat's UDF (and that it's therefore unlikely even NeoFoX will be able to help get it working for non-gif files), I'll just post my version here as well instead of making a new thread (not in an attempt to hijack your thread, NeoFoX), in case anyone wants a screen-capture version rather than an image-load version of a b/w Ascii Art creator. This is based on my "draw in HTML" script I posted here. I HIGHLY recommend that if you're running this in Vista, compile it first, then right-click the .exe and under 'compatability' tab, choose to 'disable desktop composition'.

#Include <GUIConstants.au3>
#Include <Misc.au3>
#Include <Color.au3>

Global $AsciiChars[17]=["M","N","D","8","O","Z","$","7","I","?","+","=","~",":",",","."," "]

#region GUICreation
Global $TGUI = GUICreate("T Screen Capture",200,1,100,100,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
Global $LGUI = GUICreate("L Screen Capture",1,200,100,100,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
Global $BGUI = GUICreate("B Screen Capture",200,1,@DesktopWidth-300,@DesktopHeight-100,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
Global $RGUI = GUICreate("R Screen Capture",1,200,@DesktopWidth-100,@DesktopHeight-300,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
GUISetState(@SW_SHOW,$TGUI)
GUISetState(@SW_SHOW,$LGUI)
GUISetState(@SW_SHOW,$BGUI)
GUISetState(@SW_SHOW,$RGUI)
Global $ConfigGUI = GUICreate("Config Capture to ASCII by james3mg",300,300)
GUICtrlCreateLabel("Please set the options for your screen capture",3,3,300,20)

GUICtrlCreateLabel("Top Y",60,25,50,20)
$TopInput=GUICtrlCreateInput("100",60,40,50,20)
GUICtrlCreateUpDown($TopInput,$UDS_NOTHOUSANDS)
GUICtrlCreateLabel("",60,65,40,1)
GUICtrlSetBkColor(-1,0xFF0000)

GUICtrlCreateLabel("Left X",5,60,50,20)
$LeftInput=GUICtrlCreateInput("100",5,80,50,20)
GUICtrlCreateUpDown($LeftInput,$UDS_NOTHOUSANDS)
GUICtrlCreateLabel("",60,65,1,40)
GUICtrlSetBkColor(-1,0xFF0000)

$ClickTL=GUICtrlCreateButton("Click"&@CRLF&"to set",5,25,40,30,$BS_MULTILINE)

GUICtrlCreateLabel("Bottom Y",200,250,50,20)
$BottomInput=GUICtrlCreateInput(@DesktopHeight-100,200,270,50,20)
GUICtrlCreateUpDown($BottomInput,$UDS_NOTHOUSANDS)
GUICtrlCreateLabel("",200,240,40,1)
GUICtrlSetBkColor(-1,0xFF0000)

GUICtrlCreateLabel("Right X",245,200,50,20)
$RightInput=GUICtrlCreateInput(@DesktopWidth-100,245,220,50,20)
GUICtrlCreateUpDown($RightInput,$UDS_NOTHOUSANDS)
GUICtrlCreateLabel("",240,200,1,40)
GUICtrlSetBkColor(-1,0xFF0000)

$ClickBR=GUICtrlCreateButton("Click"&@CRLF&"to set",255,255,40,30,$BS_MULTILINE)

GUICtrlCreateLabel("Quality: (1 is best and biggest file)",70,150,160,20)
$QualInput=GUICtrlCreateInput("1",70,165,50,20)
GUICtrlCreateUpDown($QualInput)
GUICtrlSetLimit(-1,9,1)

$OKButton=GUICtrlCreateButton("Go!",70,200,60,20)
#endregion GUICreation

#region ConfigLoop
GUISetState(@SW_SHOW,$ConfigGUI)
$Flashtimer=TimerInit()
$Red=true

While 1
    If TimerDiff($Flashtimer) > 1000 Then
        If $Red Then
            GUISetBkColor(0xFFFFFF,$TGUI)
            GUISetBkColor(0xFFFFFF,$LGUI)
            GUISetBkColor(0xFFFFFF,$RGUI)
            GUISetBkColor(0xFFFFFF,$BGUI)
        Else
            GUISetBkColor(0xFF0000,$TGUI)
            GUISetBkColor(0xFF0000,$LGUI)
            GUISetBkColor(0xFF0000,$BGUI)
            GUISetBkColor(0xFF0000,$RGUI)
        EndIf
        $Red = NOT $Red
        $Flashtimer=TimerInit()
    EndIf
    Switch GUIGetMsg()
        Case 0
            ContinueLoop
        Case $GUI_EVENT_CLOSE
            Exit
        Case $OKButton
            Global $Quality=Round(GUICtrlRead($QualInput))
            Global $CaptureTL[2]=[GUICtrlRead($LeftInput),GUICtrlRead($TopInput)]
            Global $CaptureBR[2]=[GUICtrlRead($RightInput),GUICtrlRead($BottomInput)]
            ExitLoop
        Case $ClickTL
            GUISetState(@SW_HIDE,$TGUI)
            GUISetState(@SW_HIDE,$LGUI)
            GUISetState(@SW_HIDE,$BGUI)
            GUISetState(@SW_HIDE,$RGUI)
            GUISetState(@SW_HIDE,$ConfigGUI)
            Do
                ToolTip("Click to set the top-left corner")
            Until _IsPressed("01")
            ToolTip("")
            GUICtrlSetData($TopInput,MouseGetPos(1))
            GUICtrlSetData($LeftInput,MouseGetPos(0))
            GUISetState(@SW_SHOW,$TGUI)
            GUISetState(@SW_SHOW,$LGUI)
            GUISetState(@SW_SHOW,$BGUI)
            GUISetState(@SW_SHOW,$RGUI)
            GUISetState(@SW_SHOW,$ConfigGUI)
        Case $ClickBR
            GUISetState(@SW_HIDE,$TGUI)
            GUISetState(@SW_HIDE,$LGUI)
            GUISetState(@SW_HIDE,$BGUI)
            GUISetState(@SW_HIDE,$RGUI)
            GUISetState(@SW_HIDE,$ConfigGUI)
            Do
                ToolTip("Click to set the bottom-right corner")
            Until _IsPressed("01")
            ToolTip("")
            GUICtrlSetData($BottomInput,MouseGetPos(1))
            GUICtrlSetData($RightInput,MouseGetPos(0))
            GUISetState(@SW_SHOW,$TGUI)
            GUISetState(@SW_SHOW,$LGUI)
            GUISetState(@SW_SHOW,$BGUI)
            GUISetState(@SW_SHOW,$RGUI)
            GUISetState(@SW_SHOW,$ConfigGUI)
        Case Else
            WinMove($TGUI,"",GUICtrlRead($LeftInput),GUICtrlRead($TopInput))
            WinMove($LGUI,"",GUICtrlRead($LeftInput),GUICtrlRead($TopInput))
            WinMove($BGUI,"",GUICtrlRead($RightInput)-200,GUICtrlRead($BottomInput))
            WinMove($RGUI,"",GUICtrlRead($RightInput),GUICtrlRead($BottomInput)-200)
    EndSwitch
WEnd
GUIDelete($TGUI)
GUIDelete($LGUI)
GUIDelete($BGUI)
GUIDelete($RGUI)
GUIDelete($ConfigGUI)
#endregion ConfigLoop

If $Quality < 1 Then Exit

Sleep(500);otherwise you can catch some of the red flashing border as it disappears

#region WriteHTML
$pixChecked=0
$TheWebpage=FileOpen(@ScriptDir&"\ASCIIpic.html",2)
FileWriteLine($TheWebpage,"<HTML><HEAD><TITLE>ASCII Picture by james3mg</TITLE></HEAD><BODY bgcolor=#FFFFFF><TABLE border='0' cellspacing='0' cellpadding='0'><TR><TD><FONT style='line-height:50%' size='-3'><PRE>")
For $y=$CaptureTL[1] To $CaptureBR[1] Step $Quality
    For $x=$CaptureTL[0] To $CaptureBR[0] Step $Quality
        
        $Red=_ColorGetRed(PixelGetColor($x,$y))
        $Green=_ColorGetGreen(PixelGetColor($x,$y))
        $Blue=_ColorGetBlue(PixelGetColor($x,$y))
        $Averaged=Round(($Red+$Green+$Blue)/3)
        $Index=Round($Averaged/15)-1
        If $Index < 0 Then $Index = 0
        If $Index > 16 Then $Index = 16
        FileWrite($TheWebpage,$AsciiChars[$Index])
        
        $pixChecked+=$Quality*$Quality
        TraySetToolTip(Round($pixChecked/(($CaptureBR[0]-$CaptureTL[0])*($CaptureBR[1]-$CaptureTL[1])),3)*100 & "% completed")
    Next
    FileWrite($TheWebpage,@CRLF)
Next
FileWriteLine($TheWebpage,"</TABLE></BODY></HTML>")
FileClose($TheWebpage)
Sleep(500)
Run(@ComSpec & ' /c start "" "'&@ScriptDir & '\ASCIIpic.html', "", @SW_HIDE)
TrayTip("","Launching created HTML file",10)
Sleep(10000)
#endregion WriteHTML
I've set it up so that it 'stretches' the image vertically as little as possible, and I find that setting the quality to 5 renders the closest-to-original-size, though it actually comes out looking best if you leave quality at 1, then zoom using your web browser to 20%... Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

Is there a way to do something similar, but just instead of convert it to a big "text image", make an string of text in image?

I mean, if we have image like this (this is an image):

Posted Image

That at the end it will be transformed to string - $String = "Text" - is it possible?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Is there a way to do something similar, but just instead of convert it to a big "text image", make an string of text in image?

I mean, if we have image like this (this is an image):

Posted Image

That at the end it will be transformed to string - $String = "Text" - is it possible?

I thought there were a couple of OCR scripts around that should do that. I know there are several apps available that will convert a bitmap to a text string but not extract actual text from the image

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 5 months later...

Getting the same error as some other people!!!

<html>
<body>
<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="BLACK"> <td> <font size="-3"><pre>
</pre>
</font>
</td></tr></table></td></tr></table>

<font face="arial"> Time took to convert: <b>0</b> sec.</font>
</body>
</html>

ROAR

[center]JSON Encoding UDF[/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...