-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from thekid/feature/metadata
Show lens model and creation date from EXIF / XMP segments
- Loading branch information
Showing
13 changed files
with
132 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
<?php namespace de\thekid\dialog\processing; | ||
|
||
use io\Folder; | ||
|
||
/** @test de.thekid.dialog.unittest.FilesTest */ | ||
class Files { | ||
private $patterns= []; | ||
private $processed= null; | ||
|
||
/** Maps file extensions to a processing instance */ | ||
public function matching(array<string> $extensions, Processing $processing): self { | ||
$this->patterns['/('.implode('|', array_map(preg_quote(...), $extensions)).')$/i']= $processing; | ||
$this->processed= null; | ||
return $this; | ||
} | ||
|
||
/** Returns a (cached) pattern to match all processed files */ | ||
public function processed(): string { | ||
if (null !== $this->processed) return $this->processed; | ||
$prefixes= []; | ||
foreach ($this->patterns as $processing) { | ||
foreach ($processing->prefixes() as $prefix) { | ||
$prefixes[$prefix]= true; | ||
} | ||
} | ||
return $this->processed= '/^('.implode('|', array_keys($prefixes)).')-/'; | ||
} | ||
|
||
/** Returns processing instance based on filename, or NULL */ | ||
public function processing(string $filename): ?Processing { | ||
foreach ($this->patterns as $pattern => $processing) { | ||
if (preg_match($pattern, $filename)) return $processing; | ||
if (!preg_match($this->processed(), $filename)) { | ||
foreach ($this->patterns as $pattern => $processing) { | ||
if (preg_match($pattern, $filename)) return $processing; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/** Yields files and their associated processing in a given folder */ | ||
public function in(Folder $origin): iterable { | ||
foreach ($origin->entries() as $path) { | ||
if ($path->isFile() && ($processing= $this->processing($path->name()))) { | ||
yield $path->asFile() => $processing; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.