public function findAllImages() { //----------------- // Image array $images = []; //------------------------ // Get objects from bucket $objects = $this->s3->getIterator('ListObjects', array('Bucket' => $this->bucket, 'Prefix' => $this->directory)); foreach ($objects as $object) { //-------------------------------------------------- // do check if object is an image and isn't to big.. if ($object['Size'] == 0) { continue; } $image = new Image(); $image->setTimezone($this->timezone); $image->parse($object['Key']); array_push($images, $image); } return $images; }
public function getImagesSequenceFromDayAndStartTime($day, $page, $starttime, $maximumTimeBetween) { if (!in_array($day, $this->getDays(-1))) { return []; } // -------------------------------------------------------------------- // Convert starttime to timestamp (= day + starttime * seconds in hour) $startTimestamp = $this->date->dateTimeToTimestamp($day, $starttime); // ------------------------------------ // Calculate timestamp of the day after $endTimestamp = $this->date->nextDayToTimestamp($day); $imagesTemp = []; $heap = $this->getImagesFromFilesystem(); $index = $this->getIndexOfTimestampFromFileFormat(); // --------------------------------------------- // Iterate while timestamp is not in current day while ($heap->valid()) { $timestamp = intval(explode('_', $heap->current())[$index]); if ($timestamp <= $endTimestamp) { break; } $heap->next(); } while ($heap->valid()) { $timestamp = intval(explode('_', $heap->current())[$index]); if ($timestamp < $startTimestamp) { break; } array_push($imagesTemp, ['timestamp' => $timestamp, 'path' => $heap->current()]); $heap->next(); } // ------------- // Sequence images $imagesTemp = array_reverse($imagesTemp); $imagesTemp = $this->getSequence($imagesTemp, $page, $maximumTimeBetween); $images = []; foreach ($imagesTemp as $image) { $path = $image['path']; $image = new Image(); $image->setTimezone($this->date->timezone); $image->parse($path); array_push($images, ['time' => $image->getTime(), 'src' => $this->filesystem->getPathToFile($image), 'metadata' => $this->filesystem->getMetadata($image)]); } return $images; }