Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 7.0.0
rev: 9.0.0a3
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/ambv/black
rev: 24.4.0
rev: 26.3.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: '7.0.0'
rev: '7.3.0'
hooks:
- id: flake8
exclude: (tests)
additional_dependencies: [
'flake8-docstrings',
'flake8-builtins',
'flake8-rst-docstrings',
'pygments',
'pep8-naming'
]
- repo: local
Expand Down
15 changes: 15 additions & 0 deletions imgparse/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,18 @@ def create_metadata_csv(imagery_path: str) -> None: # noqa: D301
)

logger.info("Metadata csv saved at: %s", metadata_csv)


@cli.command()
@click.argument("imagery_path", required=True)
def get_xmp(imagery_path: str) -> None:
"""Parse the raw XMP metadata."""
for key, value in MetadataParser(imagery_path).xmp_data.items():
print(f"{key}: {value}")


@cli.command()
@click.argument("imagery_path")
def get_altitude_source(imagery_path: str) -> None:
"""Parse the source of the altitude data."""
print("Altitude source:", MetadataParser(imagery_path).altitude_source())
9 changes: 9 additions & 0 deletions imgparse/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,15 @@ def gsd(

return alt / focal_length

def altitude_source(self) -> str:
"""Get the source of the altitude data."""
try:
return str(self.xmp_data[self.xmp_tags.ALTITUDE_SOURCE])
except KeyError:
raise ParsingError(
"Couldn't parse altitude source. Sensor might not be supported"
)

def autoexposure(self) -> float:
"""
Get the autoexposure value of the sensor when the image was taken.
Expand Down
2 changes: 2 additions & 0 deletions imgparse/xmp_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class XMPTags:
X_ACCURACY_M: str = ""
Y_ACCURACY_M: str = ""
Z_ACCURACY_M: str = ""
ALTITUDE_SOURCE: str = ""


class SenteraTags(XMPTags):
Expand All @@ -53,6 +54,7 @@ class SenteraTags(XMPTags):
X_ACCURACY_M: str = "Camera:GPSXYAccuracy"
Y_ACCURACY_M: str = "Camera:GPSXYAccuracy"
Z_ACCURACY_M: str = "Camera:GPSZAccuracy"
ALTITUDE_SOURCE: str = "Sentera:AboveGroundAltitudeSource"


class DJITags(XMPTags):
Expand Down
1 change: 1 addition & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ namespace_packages = True
explicit_package_bases = True
scripts_are_modules = True
strict = True
warn_unused_ignores = False
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "imgparse"
version = "2.0.11"
version = "2.0.12"
description = "Python image-metadata-parser utilities"
authors = []
include = [
Expand Down
Loading