Author Topic: ExifTool PHP Fast Processing Script using StayOpen and Gearman  (Read 53456 times)

TSM

  • Full Member
  • ***
  • Posts: 58
Re: ExifTool PHP Fast Processing Script using StayOpen and Gearman
« Reply #30 on: May 22, 2014, 01:50:18 PM »
Thats just the defaults for the API and as it happens we store the JSON data directly in the DB instead of using PHP serialise/unserialize, we considered json to be more portable than PHP arrays, pros and conns for everything.
It does not cause any problem putting it in PHP mode in my script as if you use fetch() it does not try and decode it, passes it raw back to you to do as you please, if you use fetchDecoded() then it will require the output format to be json.
Why I did this I do not know, but works for us.
Im just altering our internal app so we move all exiftool writing over to use the API via Gearman instead of local, before we were only optimizing the reading.

klarakos

  • Newbie
  • *
  • Posts: 3
Re: ExifTool PHP Fast Processing Script using StayOpen and Gearman
« Reply #31 on: August 01, 2014, 05:52:49 AM »
Hmmm, i think its all got slow once i moved to using fgets using a buffered socket, before i was using streams but found it incompatible with different version of php.
Ive checked and the PID does not change of the underlying perl once it has been started so its related to the fgets.
Ile look into it and get it sorted hopefully.

TSM

  • Full Member
  • ***
  • Posts: 58
Re: ExifTool PHP Fast Processing Script using StayOpen and Gearman
« Reply #32 on: August 01, 2014, 12:51:54 PM »
Hmmm, i think its all got slow once i moved to using fgets using a buffered socket, before i was using streams but found it incompatible with different version of php.
Ive checked and the PID does not change of the underlying perl once it has been started so its related to the fgets.
Ile look into it and get it sorted hopefully.

??

mauricio

  • Newbie
  • *
  • Posts: 1
Re: ExifTool PHP Fast Processing Script using StayOpen and Gearman
« Reply #33 on: June 30, 2019, 06:46:52 PM »
I have written a simple php script to run exiftool, it works correctly but I am not sure if it is the best way to implement it, they could give me advice or give their point of view.
thank you in advance for your cooperation

Code: [Select]
<?php 
  $env 
null
  
$cwd "."
  
$descriptorspec = array ( 
  
=> array ( "pipe" "r" ),  
  
=> array ( "pipe" "w" ), 
  ); 
  
 
$command escapeshellcmd("exiftool -json imagenes/test3.jpg");
 
$process proc_open($command,$descriptorspec,$pipes,$cwd,$env); 

  if (
is_resource($process)) {
   
    
fwrite($pipes[0], "-stay_open\nFalse\n");
    
fclose($pipes[0]);

    echo 
stream_get_contents($pipes[1]);
    
fclose($pipes[1]);
    
    
proc_close($process);

}
?>


jaireaux

  • Newbie
  • *
  • Posts: 1
Re: ExifTool PHP Fast Processing Script using StayOpen and Gearman
« Reply #34 on: March 13, 2020, 12:43:25 PM »
In case someone finds this forum post, as I did, seven years later, I was just looking for some good examples of using exiftool in PHP and came across this thread. I'm not working with a massive number of photos so I almost ignored it but tested it for just 10 pictures and the speed increase is dramatic. Here is the debug output I've used to time the difference between approaches.

Code: [Select]
using direct exec start time is 2020-03-13 11:04:14:773
using direct exec end time is 2020-03-13 11:04:16:900

using exif handler start time is 2020-03-13 11:04:16:900
using exif handler end time is 2020-03-13 11:04:17:495

So with this small test, using a 'shell_exec("exiftool...")' took  2,127milliseconds and using '$exif->..." took 595 milliseconds. That's almost a 75% improvement.

In summary, thanks to everyone who's kept this script alive. It's going to save me a lot of time, even with a smaller pool of images.

jlb30504

  • Newbie
  • *
  • Posts: 1
Re: ExifTool PHP Fast Processing Script using StayOpen and Gearman
« Reply #35 on: April 07, 2020, 10:50:49 AM »
Please excuse the newby question.  I take it that EXifToolBatch.php does not work in the Apache environment since PCNTL doesn't work in Apache.  Is this correct?