Exif Data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1602

    Exif Data

    Hi, does anybody have a proposal for reading the EXIF or IPTC data from uploaded photos in the document entity?
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hello,
    maybe formula
    but the return value is big data.. maybe put in a matrix or only some value

    PHP Code:
     $data = exif_read_data( 'data/Interligne.jpg' );  // document->get(fileId). to verify for have path of file and attribute.
    
    
    $data['Make'];
    $data['Model']; 
    
    Last edited by item; 05-09-2021, 09:20 PM.
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • shalmaxb
      Senior Member
      • Mar 2015
      • 1602

      #3
      Hello, I have already tried with exif_read_data in formula, without result. Some values would be enough, I know, that there is a lot saved together with an image.

      Comment

      • item
        Active Community Member
        • Mar 2017
        • 1476

        #4
        Ha just,
        formula is beforeSave..
        you need hook afterSave for have id of File ! (my opinion, id of File is dependant of id of document)
        Last edited by item; 05-09-2021, 10:43 PM.
        If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

        Comment

        • shalmaxb
          Senior Member
          • Mar 2015
          • 1602

          #5
          Meanwhile I found this Chrome Plugin: https://chrome.google.com/webstore/d...anjggkmjapkffm
          You get all Metadata of an image (in documents) by right-click. It does not work on the images in the data/upload folder.
          Would be perfect, if we could integrate something like that in espoCRM.

          Comment

          • shalmaxb
            Senior Member
            • Mar 2015
            • 1602

            #6
            I tried to create a custom function for formula, but I don`t understand the documentation and comparing the present formula functions does not help me either.
            The exif formula though should not be too difficult for a developer. It is a function already implemented in apache to read the exif data and output in an array.
            Perhaps anybody could point me in a direction.

            Comment

            • item
              Active Community Member
              • Mar 2017
              • 1476

              #7
              document hooks afterSave : just test is file is image and if isset(data['value'])
              i think that do what you will.
              can too possible by button custom service

              PHP Code:
               public function afterSave(Entity $entity, array $options = array())
              {
              
                    $data = exif_read_data( "data/upload/" .$entity->get("file")->id  );
              
                    $entity->set([ "model" => $data["Model"] , "make" => $data['Make'] ]);
              
                    $this->entityManager->saveEntity($entity, ['skipHooks' => true]);
              
              ​​​​​​​} 
              
              If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

              Comment

              • shalmaxb
                Senior Member
                • Mar 2015
                • 1602

                #8
                item , thank you for your effort, but I am totally lost. I don`t know, how to use this. What do I have to adapt for my entity.
                I put this file with some additional code (name of my entity is exifDaten):

                Code:
                <?php
                namespace Espo\Custom\Hooks\ExifDaten;
                
                use Espo\ORM\Entity;
                
                class AccountName extends \Espo\Core\Hooks\Base
                {
                public function afterSave(Entity $entity, array $options = array())
                {
                
                $data = exif_read_data( "data/upload/" .$entity->get("file")->id );
                
                $entity->set([ "model" => $data["Model"] , "make" => $data['Make'] ]);
                
                $this->entityManager->saveEntity($entity, ['skipHooks' => true]);
                
                }
                }
                into the folder
                Code:
                custom/Espo/Custom/Hooks/exifDaten/exifHook.php
                and now, what? In the documentation there is a line, how to trigger. Where? How?

                I have the impression, that nobody at espoCRM wants anybody to really learn, how to use these things, one has already to know. Pity, frustrated.

                Comment

                • item
                  Active Community Member
                  • Mar 2017
                  • 1476

                  #9
                  Hello,
                  first you say "Document" .. then i think out-of-box Document entity .. so adapt name to your entity !

                  fileName = className !
                  so for you : exifDaten .. but firstLetter must UpperCase as all entity ExifDaten

                  custom/Espo/Custom/Hooks/ExifDaten/ExifDatenHook.php

                  PHP Code:
                  <?php
                  
                  namespace Espo\Custom\Hooks\ExifDaten;
                  
                  use Espo\ORM\{
                  Entity,
                  EntityManager,
                  };
                  
                  class ExifDatenHook extends \Espo\Core\Hooks\Base
                  {
                  
                  public function afterSave(Entity $entity, array $options = array())
                  {
                       $data = exif_read_data( "data/upload/" .$entity->get("file")->id  );
                        if (isset($data['Model']) &&  isset($data['Make'])  ) {
                            // in this sample, model and make = field ..  
                            $entity->set([ "model" => $data["Model"] , "make" => $data['Make'] ]);
                  
                            $this->entityManager->saveEntity($entity, ['skipHooks' => true]);
                       }
                  
                  
                  }
                  
                  }
                  As it's a custom entity, you need to find the name of field of your file and change this to the fieldName of file : $entity->get("file")->id

                  Last edited by item; 05-11-2021, 08:04 PM.
                  If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

                  Comment

                  • shalmaxb
                    Senior Member
                    • Mar 2015
                    • 1602

                    #10
                    item, you are really kind and respectful. Thank you very much. I understand the field thing. I guess, if all is correct and i put it in the Hook folder, it should work without having to trigger anything manually? right? I will try tomorrow, when I am fresh again

                    Comment

                    • shalmaxb
                      Senior Member
                      • Mar 2015
                      • 1602

                      #11
                      Hi,
                      I still get an Error:

                      Code:
                      [2021-05-12 07:19:44] WARNING: E_WARNING: rename(data\tmp\tmpCF15.tmp,data\cache\application\classmapControllers.php): Zugriff verweigert (code: 5) {"code":2,"message":"rename(data\\tmp\\tmpCF15.tmp,data\\cache\\application\\classmapControllers.php): Zugriff verweigert (code: 5)","file":"G:\\laragon\\www\\Werkverzeichnis\\application\\Espo\\Core\\Utils\\File\\Manager.php","line":308} []
                      To explain my configuration:

                      the image, from which I want the exif data, is saved in the documents (field: "file"). I created a new entity ExifData, which only has fields according to exif data (I used the names of the exif data like "make", "model" etc.) and the relationship field to the image document. This entity is linked by a 1:1 relationship to documents, so that I can take one image from the documents and the entity ExifData should extract the exif data from that related image and populate the fields with the data. For every meta data type I have one field (not an array for all fields), to be able to use certain data for other purposes.

                      Comment

                      • item
                        Active Community Member
                        • Mar 2017
                        • 1476

                        #12
                        Hello,
                        this error is not related to hook or customisation but something permission.

                        how i do :



                        i have a custom job for test .. so before implement i do all my test in job and run job by terminal.
                        when result of job is ok.. i implement in hook or service.
                        as you see below, i have put a jpg in folder data and print result to terminal.
                        i run job: php command.php run-job JobName

                        PHP Code:
                        public function run()
                        {
                        
                        $data = exif_read_data( 'data/Interligne.jpg' );
                        
                        print_r( $data );
                        } 
                        
                        If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

                        Comment

                        • OliverNoah
                          Junior Member
                          • Mar 2024
                          • 1

                          #13
                          I'm curious if anyone has a suggestion for reading the EXIF or IPTC data from uploaded photos within the document entity. It would be really helpful for our project, so any input or proposals would be much appreciated

                          Comment

                          • eymen-elkum
                            Active Community Member
                            • Nov 2014
                            • 472

                            #14

                            Hello guys,

                            We have already developed an extension named Image Plus that includes this functionality:

                            Espocrm, Ebla Image Plus for EspoCRM enables extraction and mapping of Exif data to entity fields, facilitating organized storage and retrieval of image metadata. With the planned feature Global Image Library, users will be able to access images globally from any entity like Espocrm does with documents, so you will not be forced to duplicate sameimages.


                            CEO of Eblasoft
                            EspoCRM Expert since 2014
                            Full Stack Web Developer since 2008
                            Creator of Numerous Successful Extensions & Projects​

                            Comment

                            Working...