Hi,
is it possible to compare an image file on your Form
and one on a Homepage??
CU
AbsoluteB
Printable View
Hi,
is it possible to compare an image file on your Form
and one on a Homepage??
CU
AbsoluteB
How do you mean compare? in size?
if so then you would have to d/l that image and take the size of it (FileLen("C:\wheereveryoudownloadto")) and take the size of the image in your program and if the are = then MsgBox "whatever"
Hope taht's what you meant,
D!m
I'll explain it a lil better now that i have a couple minutes...
D/l the image
Don't forget to add the inet control. (code provided by Matthew Gates on an earlier post)Code:Dim iFile As Integer
Dim bBIN As Byte
Inet1.Cancel ' Stops any current operations
Inet1.AccessType = icUseDefault
bBIN = Inet1.OpenURL("www.vb-world.net/images/vbworld.gif", icByteArray)
iFile = FreeFile
Open "C:\vbworld.gif" For Binary Access Write As iFile
Put #iFile, , bBIN
Close iFile
Then
Get it's size and place it in a textbox or a label.
[CODE]
Text1.Text = FileLen("C:\vbworld.gif")
[CODE]
Then get the image size of the image in your form
Then under a command button or still in the form load:Code:Text2.Text = FileLen(app.path & "vbworld.gif")
And i think that's it...Code:If Text1.Text = Text2.Text Then
MsgBox "The sizes are identical"
Else
MsgBox "The sizes are not identical"
End If
sorry i was bored so i decided to explain it in full detail. Hehe i don't even know if you were talking about sizes.
Gl,
D!m
[Edited by Matthew Gates on 07-14-2000 at 02:17 AM]Code:Sub file_compare(file1 As String, file2 As String)
'this checks to files to see if they are identical
Open file1 For Binary As #1
Open file2 For Binary As #2
issame% = True
If LOF(1) <> LOF(2) Then
issame% = False
Else
Whole& = LOF(1) \ 10000 'number of whole 10,000 byte chunks
Part& = LOF(1) Mod 10000 'remaining bytes at end of file
buffer1$ = String$(10000, 0)
buffer2$ = String$(10000, 0)
Start& = 1
For X& = 1 To Whole& 'this for-next loop will get 10,000
Get #1, Start&, buffer1$ 'byte chunks at a time.
Get #2, Start&, buffer2$
If buffer1$ <> buffer2$ Then
issame% = False
Exit For
End If
Start& = Start& + 10000
Next
buffer1$ = String$(Part&, 0)
buffer2$ = String$(Part&, 0)
Get #1, Start&, buffer1$ 'get the remaining bytes at the end
Get #2, Start&, buffer2$ 'get the remaining bytes at the end
If buffer1$ <> buffer2$ Then issame% = False
End If
Close
If issame% Then
MsgBox "Files are identical", 64
Else
MsgBox "Files are NOT identical", 16
End If
'Usage:
'Call file_compare("C:\file1.exe", "C:\file\file1.exe")
End Sub
Heh Matthew's tha man. :)
Thanks a lot!
You really helped me!
But is it possible too, not to compare the filesize!
Example:
My Picture is a Tree!
The pic on the webpage is the same Tree but it stands next to a house (both objects on the same picture)
Is it possible to compare the Two trees??
CU
AbsoluteB
It would be easier to detect differences between the images as a whole than it would be for unique objects within the images. For exmaple you could compare the pixel values of both images and keep track of the number of pixels that have the same corresponing color, then inform the user the percentage of color data that the images share. You could then make suggestions based on the percentage like so:
Percentage of matching pixels
100% Same image
90 - 99% Same image minor discrepencies
50 - 89% Similar key objects within the image
0-49% different images with random matching colors
This could lead to a way to compare the trees. Find the smallest bounding box the fits both trees then compare. if you have above 80% similarites you could say that the trees are the same with minor differences.
This routine would be slow for large images though.
Research "Edge Detection".