(toolkit only) exif data from a file

I have been struggling to read out the exif data from a file with the toolkit only (no kirby cms)

I kinda want to get the title or description from exif data when doing a foreach though my pictures folder and echo them all. … example listing:

edit: in php i am able to echo it with the exif_read_data command
edit2: added readout image description

<?php 

$galerie = dir::read($dir."/galerie");
foreach($galerie as $file){
    $image = "content/galerie/".$file;
    $exif = exif_read_data($image,'IFD0',true);
        ?>
    
        <div class="sm-col sm-col-12 md-col-4 p1">
            <img src="<?php echo $image; ?>"> 
            <p class="center h4"> <?php echo $exif["IFD0"]["ImageDescription"]; ?> </p>
        </div>
<?php
}
?>

Something like this should work:

<?php foreach(dir::read($dir . '/galerie') as $file): ?>
  <?php $image = new Media('content/galerie/' . $file, url('content/galerie/' . $file)); ?>
  <?php $exif = $image->exif(); ?>

  <div class="sm-col sm-col-12 md-col-4 p1">
    <img src="<?php echo $image->url(); ?>"> 
    <p class="center h4">
      <?php echo $exif->data()["IFD0"]["ImageDescription"]; ?>
    </p>
  </div>
<?php endforeach ?>

It does the same things internally though. :wink:

<?php foreach(dir::read('content/galerie/') as $file): ?>
    
    <?php $image = new Media('content/galerie/'. $file, url(url::index().'/content/galerie/' .$file)); ?>
    <?php $exif = $image->exif(); ?>
    
        
        <div class="sm-col sm-col-12 md-col-4 p1">
            <img src="<?php echo $image->url(); ?>">
            <p> <?php echo $exif->data()['ImageDescription']; ?></p>
        </div>
<?php endforeach ?>

had to change it slightly because it was not returning proper url on the images.