Example #1
0
if (isset($uploaded_file)) {
    $exiftool = new ExifTool("");
    $exiftool->getXMPdata($uploaded_file);
    $metadatas = $exiftool->getMetadata($uploaded_file);
    /* $data = array(array("SourceFile" => "{$metadatas[0]["SourceFile"]}",
           "XMP:Title" => "image",
           "XMP:Rights" => "image",
           "XMP:Creator" => "image",
           "XMP:City" => "image",
           "XMP:Country" => "image",
           "IPTC:Credit" => "image",
           "IPTC:Source" => "image"
       ));
       file_put_contents('../data/tmp.json', json_encode($data));
       $exiftool->setMetadata($uploaded_file,"../data/tmp.json");*/
    $model = new FileModel(pathinfo(basename($uploaded_file))['filename'] . ".json", "../data/");
    $metas = $exiftool->getMetadata($uploaded_file);
    $model->saveToFile($metas);
    $img = array('name' => $metas[0]["XMP"]["Title"], 'creator' => $metas[0]['XMP']["Creator"], 'filename' => pathinfo(basename($uploaded_file))['filename'], 'url' => "app/uploads/" . $metas[0]["File"]["FileName"]);
    append_to_file(json_encode($img), "../../images.json");
}
function append_to_file($data = array(), $file)
{
    if (file_exists($file)) {
        $inp = file_get_contents($file);
        $tempArray = json_decode($inp, true);
        if (isset($tempArray) && !empty($tempArray)) {
            array_push($tempArray, $data);
        } else {
            $tempArray = [$data];
        }
Example #2
0
<?php

require_once "../Model/FileModel.php";
use App\Model\FileModel;
$model = new FileModel(pathinfo($_POST["url"])['filename'] . ".json", "../data/");
$json = $model->getFileContent();
$url = "app/uploads/";
?>
<a id="infos" class="close ti ti-close" xmlns="http://www.w3.org/1999/html"></a>
<div class="container vertical-align-middle">
    <h2 class="theme-title"> <?php 
echo $json["XMP"]["Title"];
?>
</h2>

    <div class="row">
        <div class="col-xs-5">
            <br/>
                <div class="row center-block input-group input-group-sm ">
                    <div class="col-xs-12 col-md-7">
                        <!--<form action="app/View/flickerSearch.php" method="post" enctype="multipart/form-data">-->
                        <select id="filtres" class="form-control" name="q[]" multiple="multiple"
                                data-placeholder="Search for related images on flicker..." data-width="off"
                                tabindex="-1">
                            <?php 
if (isset($json['IPTC']['Keywords'])) {
    $keywords = $json['IPTC']['Keywords'];
} else {
    if (isset($json['XMP']['Subject'])) {
        $keywords = $json['XMP']['Subject'];
    } else {
 public function uploadAction()
 {
     $uploaded_file = $this->uploader->upload();
     if (isset($uploaded_file)) {
         $this->exiftool->getXMPdata($uploaded_file);
         $metadatas = $this->exiftool->getMetadata($uploaded_file);
         $data = array(array("SourceFile" => "{$metadatas[0]["SourceFile"]}", "XMP:Title" => "image", "XMP:Rights" => "image", "XMP:Creator" => "image", "XMP:City" => "image", "XMP:Country" => "image", "IPTC:Credit" => "image", "IPTC:Source" => "image"));
         file_put_contents('app/data/tmp.json', json_encode($data));
         $this->exiftool->setMetadata($uploaded_file, "app/data/tmp.json");
         $model = new FileModel(pathinfo(basename($uploaded_file))['filename'] . ".json", "app/data/");
         $model->saveToFile($this->exiftool->getMetadata($uploaded_file));
         return $this->homeAction();
         //header('Location: http://127.0.0.1:82/projects/MVCProject/');
         //die();
     } else {
     }
 }