Skip to content

Support ignoring images based on hash when inferring nonvisual reading #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 8, 2025

Conversation

chocolatkey
Copy link
Member

@chocolatkey chocolatkey commented May 5, 2025

Toolkit portion of the work for readium/cli#15
From the changelog:

Added

  • New config option available when creating a Streamer: InferIgnoredImages, a list of hashes of images to ignore when when inferring nonvisual reading
  • analyzer.MatchImage function that compares an image link's hashes with given hashes to check for a match
  • HashValue has new String and Equal convenience functions. HashList has a new Find convenience function.

Changed

  • Renamed analyzer.Image to analyzer.InspectImage
  • Slight adjustments to behavior of manifest properties functions

@chocolatkey chocolatkey marked this pull request as ready for review May 5, 2025 07:29
@chocolatkey chocolatkey requested a review from mickael-menu May 5, 2025 07:29
@mickael-menu mickael-menu requested a review from Copilot May 7, 2025 07:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for ignoring specific images based on their hash when inferring nonvisual reading, updates the accessibility metadata inference functions, and improves the image analysis functionality.

  • Added a new config option (InferIgnoredImages) and utility functions (String, Equal, Find) for hash handling.
  • Renamed and refactored accessibility metadata inference and image inspection functions.
  • Updated tests to validate the new behavior with ignored images.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/streamer/streamer.go Introduced InferIgnoredImages config and updated the inference flow.
pkg/streamer/a11y_infer_test.go Updated tests to use the new signature for accessing accessibility metadata.
pkg/streamer/a11y_infer.go Modified inference function to return errors and handle ignored images.
pkg/manifest/properties_hash.go Added convenience functions for HashValue and HashList.
pkg/manifest/properties.go Refactored property getters to use consistent patterns.
pkg/analyzer/image_test.go Added tests for InspectImage and MatchImage functionality.
pkg/analyzer/image.go Renamed and refactored the image inspection logic to support computed hashes.
CHANGELOG.md Updated changelog to document added and changed features.

return nil
}
if enc, ok := v.(Encryption); ok {
// Is already an Encryption struct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link Properties must only contain JSON data specifically to avoid this ambiguity and facilitate the serialization of the manifest to JSON. If there are Encryption or HashList objects in Properties, they need to be serialized at the location where they are added to Properties.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mickael-menu I changed it, look OK?

@chocolatkey chocolatkey requested a review from mickael-menu May 8, 2025 06:00
Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, thank you for making the changes 👌

@chocolatkey chocolatkey merged commit 6cc1f5e into develop May 8, 2025
4 checks passed
@chocolatkey chocolatkey deleted the a11y-infer-image-ignore branch May 8, 2025 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants