<?php

use Gregwar\Image\Image;
use PHPExif\Exif;
use PHPExif\Reader\Reader as ExifReader;

$function = new Twig_SimpleFunction('base64', function ($fileName) {
  
  $documentRoot = getcwd() . '/source/';
  $newfileName = str_replace('/images', 'images', $fileName);
  $filePath = $documentRoot . $newfileName;
  
  if (file_exists($filePath)){
    $tempb64 = Image::open($filePath)->resize('24,24')->smooth('1')->jpeg($quality = 50);
    
    return Image::open($tempb64)->inline();
  }
  
  
});
