Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Image: Add an option to crop on a single web element #4259

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PaperBag42
Copy link

Added a new --selector option that takes a CSS selector and crops on the first element that matches it. Other cropping settings will work relatively to the selected element's coordinates.
Example:

# Saves the 'Google' logo from Google's site
wkhtmltoimage --selector '#hplogo' https://google.com google.jpg
# Now it's just 'oogle'
wkhtmltoimage --selector '#hplogo' --crop-x 70 https://google.com google.jpg

Unfortunately, I am still struggling with an error. After I had only added the new member to the ImageGlobal class, I started getting a segmentation fault at the end of execution. I failed to find the source, so I am hoping I could get some help from someone who had already experienced the issue.

Anyway, I hope you like this feature!

@PaperBag42
Copy link
Author

PaperBag42 commented Feb 18, 2019

Oh nice, the segfault disappeared after cleaning and rebuilding. I guess I sould have tried that earlier ¯_(ツ)_/¯

@PaperBag42 PaperBag42 changed the title [WIP] Image: Add an option to crop on a single web element Image: Add an option to crop on a single web element Feb 18, 2019
@ashkulz
Copy link
Member

ashkulz commented Apr 10, 2019

Thanks for the contribution! Can you rebase it on the latest master and add some docs in ImageCommandLineParser::outputExamples so that it's clearer that you can do negative crop arguments with this change when a selector is specified?

@PaperBag42
Copy link
Author

I added some examples, I hope they're clear.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants