Skip to content

Conversation

@kaedroho
Copy link
Contributor

@kaedroho kaedroho commented Apr 12, 2019

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
Copy link
Collaborator

@zerolab zerolab left a comment

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


self._registered_operations[image_class][operation_name] = func

def register_generic_operation(self, dependencies, operation_name, func):
Copy link
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...


class OperationNameConflict(Exception):
"""
Raised when an operation is registered that clashes with an existing generic operation's name
Copy link
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" ?

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.

3 participants