Skip to content

Generic operations - #75

Open
kaedroho wants to merge 2 commits into
mainfrom
generic-operations
Open

Generic operations#75
kaedroho wants to merge 2 commits into
mainfrom
generic-operations

Conversation

@kaedroho

@kaedroho kaedroho commented Apr 12, 2019

Copy link
Copy Markdown
Contributor

This PR implements a new feature called "generic operations". This allows third party apps to register operations that only interact with other operations and not the image directly, which means the operation could be called using any image class that supports those operations it depends on.

The first generic operation is get_pixel_count which calls get_size and get_frame_count and multiplies the results together. This operation gets automatically added on to the Pillow, Wand and OpenCV image classes as they all support the get_size and get_frame_count operations.

This will be really nice once we have the Affine Transformations API as this would allow us to implement the higher-level operations (eg, rotate, scale, etc) for all backends that support that API generically.

@kaedroho kaedroho changed the title Generic operations and get_pixel_count operation Generic operations Apr 12, 2019

@zerolab zerolab left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Makes sense. A few minor comments

Comment thread willow/registry.py

self._registered_operations[image_class][operation_name] = func

def register_generic_operation(self, dependencies, operation_name, func):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

an "operation_name, func, dependencies" order makes more sense to me.

I realise you are modelling this on register_operation above, but the distinction is that the image_class is in the right place as it defines where the operation takes place...

Comment thread willow/registry.py

class OperationNameConflict(Exception):
"""
Raised when an operation is registered that clashes with an existing generic operation's name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"Raised when the registered operation clashes with an existing operation" ?

Comment thread willow/registry.py
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