Generic operations - #75
Open
kaedroho wants to merge 2 commits into
Open
Conversation
zerolab
reviewed
Apr 12, 2019
zerolab
left a comment
Collaborator
There was a problem hiding this comment.
Makes sense. A few minor comments
|
|
||
| self._registered_operations[image_class][operation_name] = func | ||
|
|
||
| def register_generic_operation(self, dependencies, operation_name, func): |
Collaborator
There was a problem hiding this comment.
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 |
Collaborator
There was a problem hiding this comment.
"Raised when the registered operation clashes with an existing operation" ?
kaedroho
force-pushed
the
generic-operations
branch
from
April 12, 2019 14:54
a3bc873 to
ca7b023
Compare
Stormheg
force-pushed
the
main
branch
2 times, most recently
from
October 26, 2025 13:20
29089a4 to
e98b89f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_countwhich callsget_sizeandget_frame_countand multiplies the results together. This operation gets automatically added on to the Pillow, Wand and OpenCV image classes as they all support theget_sizeandget_frame_countoperations.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.