Пример #1
0
 public function setup()
 {
     $this->gopro->setMode(GoPro::MODE_PHOTO);
     sleep(3);
     $this->gopro->setPhotoResolution(06);
     sleep(3);
 }
Пример #2
0
 public function __invoke($daemon)
 {
     error_log('checking gopro files');
     $imagine = $this->imagine;
     $new = [];
     foreach ($this->gopro->getFiles(GoPro::FILTER_PHOTO) as $file) {
         if (in_array($file->getSequence(), $this->list)) {
             continue;
         }
         $new[] = $file;
     }
     error_log('found files: ' . count($new));
     foreach ($new as $file) {
         error_log('downloading photo: ' . $file->getSequence());
         $content = $this->gopro->download($file);
         error_log('opening photo: ' . $file->getSequence());
         $photo = $imagine->load($content);
         error_log('resizing watermark');
         $watermark = $this->watermark->copy();
         $photoWidth = $photo->getSize();
         $waterSize = $watermark->getSize();
         $newSize = $waterSize->widen($photoWidth->getWidth() - 1);
         $watermark->resize($newSize);
         error_log('adding watermark');
         $pos = new Point(0, $photo->getSize()->getHeight() - $watermark->getSize()->getHeight());
         $photo->paste($watermark, $pos);
         error_log('uploading photo');
         $this->darkroom->upload($file, $photo->get('jpg'));
         error_log('resizing photo');
         $photo->resize(new Box($photo->getSize()->getWidth() / 4, $photo->getSize()->getHeight() / 4));
         error_log('uploading thumb');
         $this->darkroom->upload($file, $photo->get('jpg'), 'th');
         unset($photo);
         unset($watermark);
         $this->list[] = $file->getSequence();
     }
     if (!count($new)) {
         error_log('no new files, waiting a bit');
         sleep(60);
     }
     return true;
 }