[BNM] Advice on Comparing base64 encoded images in PHP please.
Steve Esson
stevee at gmail.com
Mon Jul 2 18:32:20 BST 2007
Surely you'd only need to check the jpeg headers? So you'd only compare the
first n chars of the encoded file to see if they were identical. This would
certainly be quicker.
Calculating n is is an exercise for interested readers... and Joe
HTH
On 02/07/07, John Montgomery <john at littlespikeyland.com> wrote:
>
> > if(md5($imageStr1) != md5($imageStr2))
>
> Is going to compute the md5's for both strings, so if you just want
> to know if the two strings are different it's going to be slower than
> using a strcmp. Of course if you computed the md5's before hand and
> stored them (and kept them up-to-date) along with the base64 strings
> it would be quicker.
>
> Though, unless you're actually having speed problems you'd be far
> better off just keeping your code simple and sticking with strcmp (or
> surely just a plain old == assuming this is PHP?).
>
> cheers,
> John
>
> On 2 Jul 2007, at 17:46, joseppi c wrote:
>
> > Hi,
> >
> > I am having to store jpeg Images as base64 encoded strings.
> >
> > I would like to do a comparison between two images to see if they
> > differ.
> >
> > Should I just do a:
> >
> > if(strcmp($imageStr1, $imageStr2))
> > {
> > //do stuff
> > }
> >
> > Or speed-wise is it better to compare the MD5 result of each string:
> >
> > if(md5($imageStr1) != md5($imageStr2))
> > {
> > //do stuff
> > }
> >
> > Or does it matter?
> >
> >
> > Thanks,
> >
> > Joe.
> >
> >
> >
> >
> > ___________________________________________________________
> > What kind of emailer are you? Find out today - get a free analysis
> > of your email personality. Take the quiz at the Yahoo! Mail
> > Championship.
> > http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
> > --
> >
> > BNM Subscribe/Unsubscribe:
> > http://www.brightonnewmedia.org/options/bnmlist
> >
> > BNM info/archives:
> > http://www.brightonnewmedia.org/
> >
> > BNM powered by Wessex Networks:
> > http://www.wessexnetworks.com
> >
>
> --
>
> BNM Subscribe/Unsubscribe:
> http://www.brightonnewmedia.org/options/bnmlist
>
> BNM info/archives:
> http://www.brightonnewmedia.org/
>
> BNM powered by Wessex Networks:
> http://www.wessexnetworks.com
>
More information about the BNMlist
mailing list. Powered by Wessex Networks