horst

module
Metadata EXIF

1 post in this topic

Metadata Exif

Version 0.9.0  (currently a WIP) for PW 2.8.+ / 3.0+

This is a new attempt to add easy EXIF reading support to ProcessWire. It should be an easy and less error prone API task. Thats why the module internally uses lowercase key names for all EXIF keys and all of your requested key names. But you are not forced to use lowercase key names, you can use any mixed chars for it as you like. You will get back an array or object with keynames / properties named the same (casesensitive) way as you have passed them in with your request.

API

The module adds one hook to the Pageimage: getExif($options = null)

Without any $options passed to the method, it returns all EXIF data in a RAW multidim array.

Passing a simple list with requested key names as array to it returns an array with only the values of those requested keynames.

If you want change the output from array to object, you can use the a boolean "toObject" set to true. Additionally to this and / or any other option, you need to put your requested keynames list to the option "keys".

$rawArray = $image->getExif();

$options = array('Whitebalance', 'Flash', 'ISOSpeedRatings', 'FNumber', 'UserComment');
$array = $image->getExif($options);

$options = array('toObject' => true, 'keys' => array('whitebalance', 'flash', 'isospeedratings', 'fnumber', 'usercomment'));
$object = $image->getExif($options);

 

Possible options are

Quote

              keys = array,
                       a list with case insensitive keynames

              thumbnail = bool,
                       you can set thumbnail explicitly as own option,
                       or you can add thumbnail as keyname to keys

              toObject = bool,
                       if is false or missing, an array is returned

              unformatted = bool,
                       if explicitly set to true, you will get back unformatted (raw) values

              returnRaw = bool,
                       when no $options are set, or no $options['keys'] are set,
                       or explicitly this param is set to true,
                       the complete RAW EXIF data is returned

 

A working example

    $options = array(
        'keys' => array('ISOSpeedRatings', 'FNumber', 'Flash')
    );
    echo "<table><tr>";
    foreach($options['keys'] as $key) echo "<th>{$key}</th>";
    echo "</tr>";
    foreach($page->images as $image) {
        $exif = $image->getExif($options);
        echo "<tr>";
        foreach($exif as $value) echo "<td>$value</td>";
        echo "</tr>";
    }
    echo "</table>";

 

This will output something like:

Quote
ISOSpeedRatings    FNumber    Flash
320    f/2.2    Flash did not fire, compulsory flash mode
100    f/4.0    Flash did not fire, compulsory flash mode

 

With the boolean option "unformatted" passed as true, the output would look like:

Quote
ISOSpeedRatings    FNumber    Flash
320    11/5    16
100    40/10    16

 

For some keys, that only store something like integer values, what are not very meaningful to most of us, the module contain xyzFormatted methods. This way, it is easy to enhance and maintain the module in the future. :)

 

Help wanted

It would be nice if some of you test the module and report back if the intended API suites your needs. And you are very welcome to post suggestions for which keys you want to have a ...Formatted method.

 

Thank you!

https://github.com/horst-n/MetadataExif

 

10 people like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By benbyf
      HELLO!
      I've been working on a user messaging module which I am nearly ready to release as version 1.
      Currently I have the below functionality and I'm looking for feedback to what other things may be useful for people looking to add user to user messaging on their sites.
      compose message to one or more users known to PW js to enable tag based UI display of user names input on compose message form display all message threads with reply forms reply to message thread displaying each user name by each message in the thread display "unread" when a thread has new content that hasnt been seen by current user delete or unpublish message thread (configurable) display total message thread count display total unread threads (threads that have new replies that the current user has not seen) delete all message threads and associated data (not meant for the users to have access to) road map
      send email to user on new message to a thread they are included in
    • By louisstephens
      So I was working on a module and trying to include a library (so I could use it across the site) using $modules->get('myModule'); . However, When I go to include the library folder (modeled after the LibFlourish module created some time ago). I keep getting: 
      site/modules/MyModule/libraryName/ProcessWire\filetoinclude.php This comes with an error notifying that "failed to open stream: No such file or directory in ...".. Is ProcessWire supposed to be in the include url, or is there a way around this? Sorry, I am quite new to working with my own modules.
       
      I just noticed the sub forum regarding Development, if someone could move this to the correct area I would appreciate it.
    • By louisstephens
      I wasn't quite sure where to post this, as this is a question regarding the module (sorry if it is in the wrong place). I was wondering if anyone has used the Email to Page module and figured out a way to "move" incoming css to another field, or how to render the css so the message just renders utilizing the css. 
      Right now all of the message contents get dropped into a textarea field and display in a template as a jumbled mess. Perhaps I am missing a formatting option in the text area field to render the css and html.
    • By blynx
      Hej,
      just finished the first working version of my photoswipe bundle. https://github.com/blynx/MarkupProcesswirePhotoswipe
      Haven't published it to the module directory, yet. Wanted to wait for some feedback.
      You can add a photoswipe enabled thumbnail gallery / lightbox to your site like this. Just pass an image field to the renderGallery method:
      <?php $pwpswp = $modules->get('Pwpswp'); echo $pwpswp->renderGallery($page->nicePictures); Options are provided like so:
      <?php $galleryOptions = [ 'imageResizerOptions' => [ 'size' => '500x500' 'quality' => 70, 'upscaling' => false, 'cropping' => false ], 'loresResizerOptions' => [ 'size' => '500x500' 'quality' => 20, 'upscaling' => false, 'cropping' => false ], 'pswpOptions' => (object) [ 'shareEl' => false, 'indexIndicatorSep' => ' von ', 'closeOnScroll' => false ] ]; echo $pswp->renderGallery($page->images, $galleryOptions); More info about all that is in the readme: https://github.com/blynx/MarkupProcesswirePhotoswipe
      It is possible to customize pretty much anything by providing your own templates and scripts.
      What do you think? Any ideas, bugs, critique, requests?
      cheers
      Steffen
    • By kixe
      FieldtypeColor is on github

      Fieldtype stores a 32bit integer value reflecting a RGBA value.
      Input
      4 types of Inputfields provided
      Html5 Inputfield of type='color' (if supported by browser)    Inputfield type='text' expecting a 24bit hexcode string (RGB). Input format: '#4496dd'.
      The background color of the input field shows selected color Inputfield of type='text' expecting 32bit hexcode strings (RGB + alpha channel) Input format: '#fa4496dd' Inputfield with Spectrum Color Picker
      (Options modifiable) Inputfield type='text' with custom JavaScript and/or CSS (since version 1.0.3) Output
      Define output format under 'Details' tab in field settings. Select from the following 8 options
      string 6-digit hex color. Example: '#4496dd' string 8-digit hex color (limited browser support).  Example: '#fa4496dd' string CSS color value RGB. Example: 'rgb(68, 100, 221)' string CSS color value RGB. Example: 'rgba(68, 100, 221, 0.98)' string CSS color value RGB. Example: 'hsl(227, 69.2%, 56.7%)' string CSS color value RGB. Example: 'hsla(227, 69.2%, 56.7%, 0.98)' string 32bit raw hex value. Example: 'fa4496dd' int 32bit. Example: '4198799069' (unformatted storage value) The Fieldtype includes
      Spectrum Color Picker by Brian Grinstead

      SCREENSHOTS
      Input type=text with changing background and font color (for better contrast)

      Input type=color (in Firefox)


      Javascript based input (Spectrum Color Picker)


      Settings Output

       
      Settings Input