By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

read text from image file

100+
P: 198
Hello expert.
I want to make a program in VB in which I have an image file i,e jpg, tif etc.
How can I open this image file and read the text and generate a text file?
If there is any idea then please send me.

Thanks in advance.
Dec 22 '07 #1
Share this Question
Share on Google+
12 Replies


debasisdas
Expert 5K+
P: 8,127
How the image file contains text?

Still then if you want to open then use in a richtextbox. Using that control you can open any type of file even dll and exe also.
Dec 22 '07 #2

SammyB
Expert 100+
P: 807
hello expert
i want to make programe in vb in which i have an image file i,e jpg, tif etc
how i can open this image file and read the text and generate a text file .
if there is any idea then please send me

thaks in advance
If you are trying to create a program like OmniPage, you have an enormous task. The characters that you see in an image file are just composed of dots called pixels, there are no ascii characters. Plus, image file formats are pretty tough. HTH --Sam
Dec 22 '07 #3

100+
P: 198
hello expert
i got this code from internet searching but when i execute this code it shows the error that the "aspriseOCR.dll" file was not found but when i have no idea about how the dll file for this code is create please help me by providing some code for the following functions so that if does not show the above error
.................................................. .................................................. .......
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Declare Function OCR Lib "AspriseOCR.dll" (ByVal file As String, ByVal imageType As Long) As String
  3. Private Declare Function OCRBarCodes Lib "AspriseOCR.dll" (ByVal file As String, ByVal imageType As Long) As String
  4. Private Declare Function OCRpart Lib "AspriseOCR.dll" (ByVal file As String, ByVal imageType As Long, ByVal startX As Long, ByVal startY As Long, ByVal width As Long, ByVal height As Long) As String
  5.  
  6. Private Sub Check1_Click()
  7.     If Check1.Value = Checked Then
  8.         Command4.Enabled = True
  9.     Else
  10.         Command4.Enabled = False
  11.     End If
  12. End Sub
  13.  
  14. Private Sub Command1_Click()
  15. Dim fnum As Integer
  16.  
  17.     On Error Resume Next
  18.     dlgOpenFile.ShowOpen
  19.     If Err.Number = cdlCancel Then
  20.         ' The user canceled.
  21.         Exit Sub
  22.     ElseIf Err.Number <> 0 Then
  23.         ' Unknown error.
  24.         MsgBox "Error " & Format$(Err.Number) & _
  25.             " selecting file." & vbCrLf & _
  26.             Err.Description
  27.         Exit Sub
  28.     End If
  29.     On Error GoTo 0
  30.  
  31.     ' Read the file.
  32.     'fnum = FreeFile
  33.     'Open dlgOpenFile.FileName For Input As #fnum
  34.     'text.text = Input$(LOF(fnum), fnum)
  35.     'Close #fnum
  36.  
  37.     textPath.text = dlgOpenFile.FileNameEnd Sub
  38.  
  39. Private Sub Command2_Click()
  40.     Dim ret As String
  41.     ret = OCR(textPath.text, -1)
  42.     text.text = ret
  43. End Sub
  44.  
  45. Private Sub Command3_Click()
  46.     Dim ret As String
  47.     ret = OCRBarCodes(textPath.text, -1)
  48.     text.text = ret
  49. End Sub
  50.  
  51. Private Sub Command4_Click()
  52.     Dim ret As String
  53.     ret = OCRpart(textPath.text, -1, CLng(X.text), CLng(Y.text), CLng(W.text), CLng(H.text))
  54.     text.text = ret
  55. End Sub
  56.  
  57. Private Sub Command5_Click()
  58. End
  59. End Sub
  60.  
  61. Private Sub Form_Load()
  62.     dlgOpenFile.InitDir = App.Path
  63.     dlgOpenFile.DialogTitle = "Open File"
  64.     dlgOpenFile.Flags = _
  65.         cdlOFNFileMustExist + _
  66.         cdlOFNHideReadOnly + _
  67.         cdlOFNLongNames + _
  68.         cdlOFNExplorer
  69.     dlgOpenFile.CancelError = True
  70.     Command4.Enabled = False
  71. End Sub
.................................................. ...
If you are trying to create a program like OmniPage, you have an enormous task. The characters that you see in an image file are just composed of dots called pixels, there are no ascii characters. Plus, image file formats are pretty tough. HTH --Sam
Dec 24 '07 #4

debasisdas
Expert 5K+
P: 8,127
The referenced AspriseOCR.dll is not part of VB 6.0 . that is some thirdparty file. You need to have that file in your system to use that.
Dec 24 '07 #5

100+
P: 198
hello expert
i download this file with the code but it is not working with programe
where i will save this file or can i create my own dll file for this code if yes
then give some tips about it

thanks

The referenced AspriseOCR.dll is not part of VB 6.0 . that is some thirdparty file. You need to have that file in your system to use that.
Dec 24 '07 #6

debasisdas
Expert 5K+
P: 8,127
1.copy the file to SYSTEM32 folder
2.register the dll with windows using REGSVR32 key.

then try to use the control.
Dec 24 '07 #7

Expert 5K+
P: 8,434
For a Declare statement, I don't think you need to register the DLL. I would recommend copying it into the same directory as your program first, to try it out. But make sure you start VB in that directory, so it is the current one.
Dec 29 '07 #8

VACEPROGRAMER
100+
P: 168
You are crazy!
Try to make a DLL and save in the same folder where VB is installed or just
browse from the VB.

VACE
Dec 29 '07 #9

Expert 5K+
P: 8,434
You are crazy!
Try to make a DLL ...
Um... which of us are you responding to, VACEPROGRAMER?
Dec 31 '07 #10

VACEPROGRAMER
100+
P: 168
I'm reponding to veer!!
VACE
Jan 5 '08 #11

100+
P: 198
please responding me about my question

I'm reponding to veer!!
VACE
Jan 9 '08 #12

Expert 5K+
P: 8,434
I thought we were waiting on more detail of the latest problem. "Not working" doesn't really tell us very much.
Jan 10 '08 #13

Post your reply

Sign in to post your reply or Sign up for a free account.