pic_scanner.models.image

A module containing classes and functions for image processing, loading, and saving.

Classes

ScannedImage

A class representing a scanned image.

ScannedImageCollection

A class representing a collection of scanned images.

Functions

get_description(class_name)

Get the description of a label.

create_scanned_image(result_struct)

Create a scanned image from a result dictionary.

Module Contents

pic_scanner.models.image.get_description(class_name)

Get the description of a label.

Parameters:

class_name (str) – The name of the label.

Returns:

The description of the label.

Return type:

str

class pic_scanner.models.image.ScannedImage(image_path: str | pathlib.Path, auto_checksum: bool = True, backup_path: str | pathlib.Path = None)

A class representing a scanned image.

Properties:
image_path (str, Path):

The path of the image.

backed_up (bool):

The backup status of the image.

concerns (list):

The list of concerns associated with the image.

concern_count (int):

The number of concerns associated with the image.

concern_names (list):

The names of the concerns associated with the image.

Parameters:
  • image_path (Union[str, pathlib.Path])

  • auto_checksum (bool)

  • backup_path (Union[str, pathlib.Path])

add_concern(concern)

Add a concern to the scanned image.

backup(backup_dir, backup_name, **kwargs)

Backup the image.

create_concerns(result)

Create concerns from a result dictionary.

get_concerns()

Get the concerns associated with the image.

get_concerns_by_name(name)

Get the concerns associated with the image by name.

has_concern(name, case_sensitive)

Check if the image has a concern.

move(new_dir, new_name)

Move the image to a new directory.

image_path
property auto_checksum
Get the auto checksum status of the image.
Returns:

The auto checksum status of the image.

Return type:

bool

property backup_path
Get the backup path for the image.
Returns:

The backup path for the image.

Return type:

Path

property backed_up: bool

Get the backed up status of the image.

Returns:

The backed up status of the image.

Return type:

bool

property checksum
Get the checksum of the image.
Returns:

The checksum of the image.

Return type:

str

property concerns
Get the concerns associated with the image.
Returns:

The concerns associated with the image.

Return type:

list

property concern_count
Get the number of concerns associated with the image.
Returns:

The number of concerns associated with the image.

Return type:

int

property concern_names
Get the names of the concerns associated with the image.
Return type:

list

property default_backup_path
Get the default backup path for the image.
Returns:

The default backup path for the image.

Return type:

Path

property getting_checksum
Get the getting checksum status of the image.
Returns:

The getting checksum status of the image.

Return type:

bool

property point_of_interests
Get the points of interest associated with the image.
Returns:

The points of interest associated with the image.

Return type:

list

add_concern(concern)

Add a concern to the scanned image.

Parameters:

concern (Concern) – The concern to add to the scanned image.

Returns:

None

add_point_of_interest(point_of_interest)

Add a point of interest to the scanned image.

Parameters:

point_of_interest (PointOfInterest) – The point of interest to add to the scanned image.

Returns:

None

backup(backup_dir=None, backup_name=None, **kwargs)

Backup the scanned image.

Parameters:
  • backup_dir (str, Path) – The directory to store the backup.

  • backup_name (str) – The name of the backup file.

Returns:

The path of the backup file.

Return type:

Path

create_concerns(result)

Create concerns from a result dictionary.

Parameters:

result (dict) – The result dictionary.

Returns:

None

get_checksum()

Get the checksum of the image.

Returns:

The checksum of the image.

Return type:

str

get_concerns()

Get the concerns associated with the image.

Returns:

The concerns associated with the image.

Return type:

list

get_concerns_by_name(name, case_sensitive=False)

Get the concerns associated with the image by name.

Parameters:
  • name (str) – The name of the concern.

  • case_sensitive (bool) – If the check should be case-sensitive.

Returns:

The concerns associated with the image by name.

Return type:

list

has_concern(name, case_sensitive=False)

Check if the image has a concern by name.

Parameters:
  • name (str) – The name of the concern.

  • case_sensitive (bool) – If the check should be case sensitive.

Returns:

True if the image has the concern, False otherwise.

Return type:

bool

has_point_of_interest(name, case_sensitive=False)

Check if the image has a point of interest by name.

Parameters:
  • name (str) – The name of the point of interest.

  • case_sensitive (bool) – If the check should be case sensitive.

Returns:

True if the image has the point of interest, False otherwise.

Return type:

bool

move(new_dir, new_name=None)

Move the image to a new directory.

Parameters:
  • new_dir (str) – The new directory to move the image to.

  • new_name (str) – The new name of the image.

Returns:

None

class pic_scanner.models.image.ScannedImageCollection

Bases: pic_scanner.common.types.ScannedImageCollection

A class representing a collection of scanned images.

Properties:
images (list):

The list of scanned images.

concern_names (list):

The names of the concerns associated with the images in the collection.

concerns (list):

The concerns associated with the images in the collection.

concern_count (int):

The number of concerns associated with the images in the collection.

image_count (int):

The number of images in the collection.

image_paths (list):

The paths of the images in the collection.

remove_image(image)

Remove a scanned image from the collection.

Parameters:

image (ScannedImage) – The scanned image to remove from the collection.

Returns:

None

get_all_with_concern(concern_name: str, case_sensitive=False, score_threshold=None)

Get all images with a specific concern.

Parameters:
  • concern_name (str) – The name of the concern.

  • case_sensitive (bool) – If the check should be case-sensitive.

  • score_threshold (Union[float, int], optional) – The threshold for the concern score.

Returns:

A list of images with the concern.

Return type:

list

get_image(image_path)

Get a scanned image from the collection by path.

Parameters:

image_path (str, Path) – The path of the scanned image.

Returns:

The scanned image.

Return type:

ScannedImage

get_concerns()

Get the concerns associated with the images in the collection.

Returns:

The concerns associated with the images in the collection.

Return type:

list

get_concerns_by_name(name)

Get the concerns associated with the images in the collection by name.

Parameters:

name (str) – The name of the concern.

Returns:

The concerns associated with the images in the collection by name.

Return type:

list

get_concerns_by_score(score)

Get concerns by score.

Parameters:

score – The score of the concern.

Returns:

A list of concerns with the given score.

Return type:

list

get_concern_names()

Get the names of the concerns associated with the images in the collection.

Returns:

The names of the concerns associated with the images in the collection.

Return type:

list

move_all_with_concern(new_dir, concern_name)

Move all images with a specific concern to a new directory.

Parameters:
  • new_dir (str, Path) – The new directory to move the images to.

  • concern_name (str) – The name of the concern.

Returns:

None

property concern_names
Get the names of the concerns associated with the images in the collection.
Returns:

The names of the concerns associated with the images in the collection.

Return type:

list

property concerns
Get the concerns associated with the images in the collection.
Returns:

The concerns associated with the images in the collection.

Return type:

list

property concern_count
Get the number of concerns associated with the images in the collection.
Returns:

The number of concerns associated with the images in the collection.

Return type:

int

property image_count
Get the number of images in the collection.
Returns:

The number of images in the collection.

Return type:

int

property image_paths
Get the paths of the images in the collection.
Returns:

The paths of the images in the collection.

Return type:

list

pic_scanner.models.image.create_scanned_image(result_struct)

Create a scanned image from a result dictionary.

Parameters:

result_struct (dict) – The result dictionary.

Returns:

The scanned image.

Return type:

ScannedImage