How to compare images in Access


CAn any body tell em how to compare two images in Accessc.Actually I have Photo filed filed datatype is oleobject which stores images.Now i want to know how may duplicate images is there.

Thanks in advance

more ▼

asked Sep 28, 2010 at 02:57 AM in Default

avatar image

181 20 23 27

(comments are locked)
10|1200 characters needed characters left

4 answers: sort voted first

How do you want to compare them, as a binary file or as a side-by-side view of the images? Are the images stored on a file server too? There are plenty of file comparison tools that could parse a directory and give you the results...

more ▼

answered Sep 28, 2010 at 03:54 AM

avatar image

Fatherjack ♦♦
43.7k 79 98 117

I want to compare side by side view.Images are not stored on file server.

Sep 28, 2010 at 04:29 AM user-806

But side by side comparison will be painfully slow compared to an automated comparison.

However, you could create a form that loads two images from the database - one image that remains constant and the second would be used to load a comparison image and then allow you to mark it as a duplicate.

Sep 28, 2010 at 04:34 AM WilliamD
(comments are locked)
10|1200 characters needed characters left

You could try generating a hash of the binary data and comparing that for each entry in your table.

As it is Access, you could do that in VB. I have no idea how inefficient that would be though, most probably not very. It would be better to do it as Fatherjack mentioned by using a comparison tool on a directory structure - there are lots of free versions available and most should be fast enough.

more ▼

answered Sep 28, 2010 at 04:08 AM

avatar image

26.2k 18 34 48

(comments are locked)
10|1200 characters needed characters left

I would start off creating a query comparing datasize of the OLE Objects. I believe that can be done using the LenB-function. Create a query that does **GROUP BY LenB(OLEField) HAVING COUNT()>1*. That would limit the number of objects you need to compare.

Next step would be to open the query from a VBA-Module, and compare the rows with identical sizes for the OLE Object.

Comparing two objects can be done by storing them in Byte arrays, and using StrConv function to compare them. Here's a VBA function that could possibly be used for that purpose.

 Function OleObjectEquals(a() As Byte, b() As Byte) As Boolean
     If StrConv(a, vbUnicode) = StrConv(b, vbUnicode) Then
         OleObjectEquals = True
         OleObjectEquals = False
     End If
 End Function
more ▼

answered Sep 28, 2010 at 06:39 AM

avatar image

Magnus Ahlkvist
21.2k 19 39 42

(comments are locked)
10|1200 characters needed characters left

It largely depends on what you mean by compare. If you just want to see if the images are identical in a byte for byte since and you really want to use Access, then I think Magnus has the best answer you will find. With that said, Access is probably not a good tool for this task unless you have some truly compelling reason to use it.

I personally would consider Python where you have access to bsdiff ( http://www.daemonology.net/bsdiff/ ) and difflib ( http://docs.python.org/library/difflib.html ) either of which will provide you a comparison very effeciently and with a minimum of code. C# would also be a good choice for that and Microsoft very helpfully provides a full tutorial for doing it effeciently at http://support.microsoft.com/default.aspx?scid=kb;EN-US;320348

Now, if you mean you want the program to do a sophisticated analysis to tell you the amount of difference, then Access is certainly not the right tool and you will be far outside my knowledge.

And finally, if you want to provide the two pictures side by side so that the user can personally compare them, then just create two image objects in your form. Then you can use VBA to change the images they have. The code to change the image is as simple as:

 ImageName.Picture = "Drive:\Path\File.jpg"

You can of course include that in a more sophisticated procedure that decide which pictures to show the user.

more ▼

answered Sep 28, 2010 at 09:28 AM

avatar image

15.6k 22 51 38

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Sep 28, 2010 at 02:57 AM

Seen: 1537 times

Last Updated: Sep 28, 2010 at 03:09 PM

Copyright 2016 Redgate Software. Privacy Policy