Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add cropping for LocalImages #169
In re: #77
This PR adds cropping functionality to LocalImages. A new argument to Markdown image inlines,
The user now has the option to crop local images via a
PlaidWeb/publ-site#4 includes one example/test of resizing and cropping simultaneously in the "Image rendition tests" entry. One can test this functionality in an entry against other crop values—not included in the PR is the test
fluffy-critter left a comment
So, the reason I never got around to adding this functionality myself is that I thought there shouldn't be any need to pass
However: I realize now that I was massively overthinking this. :) My reasoning around it was that this would both perform better (which doesn't matter because the output is cached indefinitely, and PIL might even optimize it out already) and would produce more humane rendition image filenames (which doesn't matter because people shouldn't be directly using rendition filenames to begin with). I also had a vague notion that it would produce better image quality although when I actually think about that it makes no sense either.
So, historical rambling aside, this looks pretty good and is nice and straightforward. A few things I'd like to see before I merge it in:
Seeing some of the added pylint exclusions also has me wanting to refactor some things here but don't worry about that. :)
Regarding support for
Ah, heh, looking at the Pillow docs,
Oh, and regarding how to handle the user error of a crop rectangle exceeding the original bounds, I think just letting Pillow handle that is fine.