You can pass a dictionary of options to any imgkit method to control the conversion process. These options correspond to wkhtmltoimage command-line flags (remove the -- prefix).
- Boolean/Flag options: Use
None, False, or '' (e.g., {'no-outline': None}). - Repeatable options: Use a list or tuple (e.g.,
cookie, custom-header). - Options with multiple values: Use a 2-tuple (e.g.,
('Header-Name', 'Value')). - Quiet mode: To suppress output, use
{'quiet': ''}.
options = {
'format': 'png',
'crop-h': '3',
'crop-w': '3',
'crop-x': '3',
'crop-y': '3',
'encoding': "UTF-8",
'custom-header' : [
('Accept-Encoding', 'gzip')
],
'cookie': [
('cookie-name1', 'cookie-value1'),
('cookie-name2', 'cookie-value2'),
],
'no-outline': None
}
imgkit.from_url('http://google.com', 'out.png', options=options)