Skip to content

hertzforge.core.photos

photos

Photos: pictures of the test, saved in the project.

A Photos object is an ordered set of named images, such as the setup and instrumentation photos used in a test report. It keeps the file bytes exactly as read (PNG or JPEG), so nothing is re-encoded and the same bytes go into the project file and the report.

Classes:

Name Description
Photos

Named images, in the order they were added.

Classes

Photos

Photos(names: Sequence[str] | None = None, formats: Sequence[str] | None = None, images: Sequence[bytes] | None = None)

Named images, in the order they were added.

Setup photos (where the accelerometers were placed, how the test article was supported) belong with the data they document, so they are a project object like any other and are saved in the .hforge file. The bytes are kept encoded as they were read, not decoded into arrays, because a report embeds them and re-encoding a JPEG to store it would reduce its quality.

Attributes: names: The name of each photo, which is also its caption in a report. formats: The encoding of each, for example 'png' or 'jpeg'. images: The encoded bytes, one per photo.

Raises ValueError if names, formats and images differ in length.

Methods:

Name Description
rename

Rename the photo at index.

delete_photos

Remove the photos at picks (indices).

add_file

Add a PNG or JPEG file, named after the file without its extension.

Attributes:

Name Type Description
num_photos int

How many photos there are.

Attributes
num_photos property
num_photos: int

How many photos there are.

Methods:
rename
rename(index: int, name: str) -> None

Rename the photo at index.

Raises ValueError if the name is blank or another photo already has it.

delete_photos
delete_photos(picks: Sequence[int]) -> None

Remove the photos at picks (indices).

add_file
add_file(path: str | PathLike) -> str

Add a PNG or JPEG file, named after the file without its extension.

If a photo already has that name, a number is added, as in 'setup (2)'. Returns the name given to the photo. Raises ValueError for any other kind of file.