Announcement

Collapse
No announcement yet.

EXIF Reader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    EXIF Reader

    After looking at some code Claudiu posted recently on mivascript.com it got me thinking.

    While I couldn't get Claudiu's function to work as specified, it did get me thinking about asciichar and asciivalue, and as a result I now have a proof of concept EXIF reader function working in Mivascript.

    It's still a bit rough, but once I've tidied it up a bit, I'll post it so that folk can test it with a range of images from different cameras and image editing software. If anyone's dead keen let me know and I can post what I've got so far. I'm thinking an LGPL license would be appropriate so people can use it with commercial proejcts, but improvements are made available to everyone.

    I've always been a bit envious of how Flickr can pick up any image information added by Picasa, Photoshop and so on and display it, and thought it would be great to have that functionality in Mivascript.

    I haven't really played with GD functions, but from what I understand, they strip out any EXIF data?

    Ultimately what would be nice would be the ability to add the EXIF data back into a file after it's been modified using the gd functions.
    Christopher Cookson
    Create IT Powered by Webpression CMS

    #2
    Re: EXIF Reader

    Nice job Christopher ... can't wait to see it. Is it going to be open source or close source ?

    Cheers
    Claudiu
    Zen Radio : Relax :) : www.zenradio.fm
    MivaScript Tutorials & Scripts : www.mivascript.org

    Comment


      #3
      Re: EXIF Reader

      Hi Claudiu,
      here it is attached. You're welcome to host it on Mivascript.org (As you can see from the license I've chosen, I can't stop you anyway.) It needs a home somewhere for people to contribute updates. I can host it myself, but Mivascript.org makes sense, as it keeps different projects all in one place.
      It needs lots of testing with images from different cameras and software, so it makes sense that it should be open source so that as many people as possible can use it and improve it, but I've chosen the LGPL license so that it's possible to link to it with closed source software.
      Attached Files
      Christopher Cookson
      Create IT Powered by Webpression CMS

      Comment


        #4
        Re: EXIF Reader

        Well, that's a nice work here :)

        The only thing I could say that bothers me, is the filename in the example (although it's not very important, ppl could get unexpected results).

        I've worked with lots of uploaded images and I found that it's very common to see images with names like 'somethin.new.jpg'... so my only advice would be to change the line:

        PHP Code:
        <mvassign name="l.filename" value="{gettoken(l.imagepath,'.',1)}"
        into:

        PHP Code:
        <mvassign name="l.filename" value="{glosub(l.imagepath,'.'$gettoken(l.imagepath,'.',(len(l.imagepath)-len(glosub(l.imagepath,'.',''))+1)),'')}"
        Anyhow, thank you for sharing this... it's a great job :-) I'll make an article on ms org and let you know to see and validate it !

        Thank you
        Claudiu
        Zen Radio : Relax :) : www.zenradio.fm
        MivaScript Tutorials & Scripts : www.mivascript.org

        Comment


          #5
          Re: EXIF Reader

          Here is a new version of the file for testing. Changes are included in the source, but key changes are a bug that meant images with EXIF data in Motorola byte order weren't displaying data correctly.
          Also, I've cleaned up the code a lot, and now combined with GD functions, the library is extracting thumbnails!
          I've also incorporated your suggestion Cladiu.
          Apart from the camera data, the thumbnail data was one of my key goals.
          After reading through gd documentation, it seemed to be pretty memory intensive if you have to uncompress a large JPG image into a GD object just to resize it to create a thumbnail.
          If the image already include a JPG thumbnail, it means you can keep the main image compressed and just load the thumbnail data into the GD variable which will be far more efficient.

          There are still plenty of bugs: XMP data doesn't seem to be working consistently with all images, but this is a significant step forward.
          Attached Files
          Christopher Cookson
          Create IT Powered by Webpression CMS

          Comment


            #6
            Re: EXIF Reader

            Oops! spotted another bug that prevents the thumbnail generating properly
            Lines 41-42 of the file should read:
            Code:
            <mvif expr="{l.metadata:exif:thumbnail:Compression EQ 6}">
            			<mvassign name="l.image" value="{gdImageCreateFromJpegMem(l.metadata:exif:thumbnail:JPGData)}" />
            Christopher Cookson
            Create IT Powered by Webpression CMS

            Comment


              #7
              Re: EXIF Reader

              Ok, got the last version. Nicely done for the mods. and good idea about the thumbnails. Hopefully, I'll finish my article for this week-end and put it on the website...

              Thank you for sharing your work :-)
              Claudiu
              Last edited by Rick Wilson; 09-09-11, 06:04 AM.
              Zen Radio : Relax :) : www.zenradio.fm
              MivaScript Tutorials & Scripts : www.mivascript.org

              Comment


                #8
                Re: EXIF Reader

                I realize this thread is pretty old but I'm looking into recording then stripping EXIF data off user uploaded photos.

                I've been doing a lot of clean up/updating of the code and ran across something odd.

                In the read_ifd() function, there is an mvif statement:
                Code:
                <mvif expr="{l.tag_value EQ 34665}">
                    <mvassign name="l.exif_offset" value="{l.value}" />
                </mvif>
                However, no where else in the code does it mention l.tag_value; so this is never true and l.exif_offset is never set. There is a l.tagvalue (no underscore) used quite a bit in the function though. So I would guess that it's just a typo, but it's kind of moot.

                Even if l.exif_offset was to get set, it is only mentioned in one other place; but in a completely different function, exif(). So setting it locally in read_idf() is pointless as the value is never passed back into the exif() function which tries to use it.

                Has there been any other updates to this code since a year ago? I didn't see it on ms.org or ms.com.

                Thanks

                Comment


                  #9
                  Re: EXIF Reader

                  Scott, I think that might be an artifact from early on when I had everything in one function. I think it's surplus to requirements now.

                  I haven't done much on the script in ages, but your post has got me interested again.
                  The new miva_hex_encode and miva_hex_decode functions as of empresa 5.17 make things easier.

                  I'm actually trying to move away from Mivascript as it isn't all that helpful on the resume, and it lacks some of the language features and tools of other languages, however I have quite a few sites running my CMS, and my efforts to convert it all to PHP has turned out to be a bigger task than I at first anticipated, so I'll still be writing some Mivascript in the meantime.

                  I've implemented equivalents of the PHP EXIF functions in Mivascript, but this is a classic case of why I'm moving away from Mivascript. I love the challenge, but I don't get paid for writing functionality that already exists in other languages, whereas with PHP if I need that functionality, it's just there, and I can get on with paid work. I guess the same can be said in reverse to some extent, with some features that Mivascript implements very nicely that are a bit messy or non-existent in PHP, but generally PHP offers a richer set of features, and it's far more widely used.

                  I'll post an update tomorrow the mivascript equivalents of all the PHP functions are a bit more completely implemented, and I've had a chance to tidy up the code a bit.

                  HINT to Mivascript developers miva_decimal_encode/decode functions to take a string of bytes and convert to/from a decimal integer would be nice, as would bintodec/dectobin functions.
                  Christopher Cookson
                  Create IT Powered by Webpression CMS

                  Comment


                    #10
                    Re: EXIF Reader

                    Originally posted by virtualkiwi View Post
                    Scott, I think that might be an artifact from early on when I had everything in one function. I think it's surplus to requirements now.

                    I haven't done much on the script in ages, but your post has got me interested again. The new miva_hex_encode and miva_hex_decode functions as of empresa 5.17 make things easier .... I'll post an update tomorrow the mivascript equivalents of all the PHP functions are a bit more completely implemented, and I've had a chance to tidy up the code a bit.
                    I'd appreciate that. In the end, I don't really need to read anything from the image. It was just an exercise in "How is it done, and can I do it?". I started working on reading the GPS data and it proved to be quite, how do you say, enlightening. Or is the word aggravating? I mix them up so often.

                    Originally posted by virtualkiwi View Post
                    I'm actually trying to move away from Mivascript as it isn't all that helpful on the resume, and it lacks some of the language features and tools of other languages, however I have quite a few sites running my CMS, and my efforts to convert it all to PHP has turned out to be a bigger task than I at first anticipated, so I'll still be writing some Mivascript in the meantime.
                    I feel ya... I've got my own website that I've thought about moving to PHP. There is just no simple apple-to-apple conversion.

                    Originally posted by virtualkiwi View Post
                    I've implemented equivalents of the PHP EXIF functions in Mivascript, but this is a classic case of why I'm moving away from Mivascript. I love the challenge, but I don't get paid for writing functionality that already exists in other languages...
                    Been there; done that. I've done the same with creating a miva version of PHP's Date() function. But I enjoy the challenge of making utilities. Over the years I've designed:
                    -a universal numeric "-base" converter; converts decimal to anything from base-2 to base-62 and back again.
                    -calendar functions so that given any time_t, they can figure out the bounding time_t values of "today", "yesterday", "this week as seven days", "this week as starts on Sunday", and so forth.
                    -a colorizing routine that given any foreground and background combination will create readable darker and lighter variations. Great for doing rollover buttons.
                    - a directory browser; with configurable top-level and filters to only show certain file types.

                    Now if we could only find a way to market/make money off all this...

                    Scott
                    Last edited by Scott McCollough; 06-05-13, 11:53 AM.

                    Comment

                    Working...
                    X