HtmlWebShot - A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features.

Overview

HtmlWebShot

PyPI version Codacy Badge Licencse PyPI downloads

A python3 package which Can Create Images From url, Html-CSS, Svg and from any readable file and texts with many setup features.

Setup & Installation

  • Install HtmlWebShot:

    $ pip3 install htmlwebshot
  • Install wkhtmltopdf:

    • Debian/Ubuntu:
      $ apt-get install wkhtmltopdf -y  
    • MacOs:
      $ brew install homebrew/cask/wkhtmltopdf
    • Alternative Support
      $ wget https://github.com/1Danish-00/HtmlWebShot/raw/main/script.sh | sh
      
    • Win / Arch / Others
      click here

Usage

Import & Instantiate

from htmlwebshot import WebShot
shot = WebShot()
Multiple Arguments
  • size: (int , int) : tuple : height, width default: full-screen
  • quality: int : between 1 to 100
  • delay: float : delay time in sec to load page
  • flags: list : know More
  • params: dict : know more
  • config: path setup know more

Simple Method

Using Url

shot.create_pic(url="https://google.com")

Using Html File

shot.create_pic(html="myfile.html", output="picture.jpg")

Using Html with CSS

via files

shot.create_pic(html="myfile.html", css="background.css", output="picture.jpg")

via string

Hello World

Write something about the world.

""" css = "body {background: pink;} p {color: red;}" shot.create_pic(html=html, css=css, output="picture.jpg") ">
html = """

Hello World

Write something about the world.

"""
css = "body {background: pink;} p {color: red;}" shot.create_pic(html=html, css=css, output="picture.jpg")

Using Svg Or Any Other Readable File/Text

shot.create_pic(other="violin.svg", output="picture.jpg")
text = "What should I write here???"
shot.create_pic(other=text, size=(100,200))

You can use with async too

await shot.create_pic_async( # parameters are same for both

Some Examples

Hello World

Write something about the world.

""" css = "body {background: pink;} p {color: red;}" shot.create_pic(html=html, css=css, output="picture.jpg") ">
from htmlwebshot import WebShot
shot = WebShot()

shot.size = (110, 270)
shot.quality = 80  # maximum 100

html = """

Hello World

Write something about the world.

"""
css = "body {background: pink;} p {color: red;}" shot.create_pic(html=html, css=css, output="picture.jpg")
Click Here To See Output Image Of Above Code. sample1
from htmlwebshot import WebShot
shot = WebShot()

shot.quality = 100
shot.params = {"--crop-x":300, "--crop-w": 400}

shot.create_pic(html="profile.html", css="profile.css")
Click Here To See Output Image Of Above Code. sample2

Click For More Examples
from htmlwebshot import WebShot
shot = WebShot()

shot.quality = 85
shot.flags = ["--enable-javascript"]

shot.create_pic(html="jsgraph.html")
Click Here To See Output Image Of Above Code. sample4
from htmlwebshot import WebShot
shot = WebShot()

shot.flags = ["--quiet"]
shot.quality = 100

shot.create_pic(other="violin.svg", size=(500,600))
Click Here To See Output Image Of Above Code. sample3

Flags Uses

Click Here To Check All Flags:
  • --quiet: Be less verbose
  • --disable-smart-width: To force size to be accurate
  • --custom-header-propagation: Add HTTP headers specified by flag --custom-header for each resource request
  • --no-custom-header-propagation: Don't Add HTTP headers specified by flag --custom-header for each resource request
  • --disable-javascript: Don't allow web pages to run javascript
  • --enable-javascript: Allow web pages to run javascript
  • --proxy-hostname-lookup: Use the proxy for resolving hostnames
  • --stop-slow-scripts: Stop slow running javascripts
  • --no-stop-slow-scripts: Don't Stop slow running javascripts
from htmlwebshot import WebShot
shot = WebShot()
shot.flags = ["--quiet", "--enable-javascript", "--no-stop-slow-scripts"]

Available Params

Click Here To Check All Params options:
  • --bypass-proxy-for: Bypass proxy for host (repeatable)
  • --cookie: Set an additional cookie (repeatable), value should be url encoded.
  • --cookie-jar: Read and write cookies from and to the supplied cookie jar file
  • --crop-h: Set height for cropping
  • --crop-w: Set width for cropping
  • --crop-x: Set x coordinate for cropping
  • --crop-y: Set y coordinate for cropping
  • --custom-header: Set an additional HTTP header (repeatable)
  • --encoding: Set the default text encoding, for input
  • --format: Output file format
  • --minimum-font-size: Minimum font size
  • --password: HTTP Authentication password
  • --post: Add an additional post field (repeatable)
  • --post-file: Post an additional file (repeatable)
  • --proxy: Use a proxy
  • --run-script: Run this additional javascript after the page is done loading (repeatable)
  • --ssl-crt-path: Path to the ssl client cert public key in OpenSSL PEM format, optionally followed by intermediate ca and trusted certs
  • --ssl-key-password: Password to ssl client cert private key
  • --ssl-key-path: Path to ssl client cert private key in OpenSSL PEM format
  • --user-style-sheet: Specify a user style sheet, to load with every page
  • --username: HTTP Authentication username
  • --window-status: Wait until window.status is equal to this string before rendering page
  • --zoom: Use this zoom factor
from htmlwebshot import WebShot
shot = WebShot()
shot.params = {
    "--custom-header": "Accept-Encoding gzip",
    "--minimum-font-size": 50,
    "--format": "png",
    "--zoom": 10,
    }

Config Path

If you installed pkg directly then no need to configure it, It'll auto configure.
But If u installed externally then you have to setup config path.

from htmlwebshot import WebShot, Config
shot = WebShot()
shot.config = Config(wkhtmltopdf="/path/to/wkhtmltopdf", wkhtmltoimage="/path/to/wkhtmltoimage")
You might also like...
A simple programme for converting url into a qr code (.png file)
A simple programme for converting url into a qr code (.png file)

QrTk A simple lightweight programme for converting url into a qr code (.png file) Pre-Requisites Before installing the programme , you need to run the

missing-pixel-filler is a python package that, given images that may contain missing data regions (like satellite imagery with swath gaps), returns these images with the regions filled.
missing-pixel-filler is a python package that, given images that may contain missing data regions (like satellite imagery with swath gaps), returns these images with the regions filled.

Missing Pixel Filler This is the official code repository for the Missing Pixel Filler by SpaceML. missing-pixel-filler is a python package that, give

Snowfall - helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions
Snowfall - helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions

snowfall helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions usage examples: from image_h

Xmas-Tree-GIF-Tool - Convert any given animated gif file into an animation in GIFT CSV format

This repo is made to participate in Matt Parker's XmasTree 2021 event. Convert a

A collection of python scripts which help you programatically create PNGs or GIFs
A collection of python scripts which help you programatically create PNGs or GIFs

A collection of python scripts which help you programatically create PNGs or GIFs and their Metadata in bulk with custom rarity rates, upload them to OpenSea & list them for sale.

A python based library to help you create unique generative images based on Rarity for your next NFT Project
A python based library to help you create unique generative images based on Rarity for your next NFT Project

Generative-NFT Generate Unique Images based on Rarity A python based library to help you create unique generative images based on Rarity for your next

📷 Python package and CLI utility to create photo mosaics.
📷 Python package and CLI utility to create photo mosaics.

📷 Python package and CLI utility to create photo mosaics.

Transfers a image file(.png) to an Excel file(.xlsx)
Transfers a image file(.png) to an Excel file(.xlsx)

Transfers a image file(.png) to an Excel file(.xlsx)

This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specialized data structure called VP-Tree which makes searching an image on a dataset of 100Ks almost instantanious
This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specialized data structure called VP-Tree which makes searching an image on a dataset of 100Ks almost instantanious

Offline Reverse Image Search Overview This app finds duplicate to near duplicate images by generating a hash value for each image stored with a specia

Comments
  • [BUG REPORT]: Query String on Local File Not Working

    [BUG REPORT]: Query String on Local File Not Working

    Your System?

    Windows 10

    Version

    3.8

    Version

    latest

    What happened?

    When I try to take a screenshot of a local file whilst providing a URL query string, it does not work. My assumption is that it tried to look for a file which contains the query string in the filename.

    Paste Your Codes.

    shot.create_pic(html=r"folder\file.html?username=hi", css=r"folder\tweet.css", output="output.jpg")
    

    Your Error Logs.

    It does not output an error
    
    bug 
    opened by i-vone 3
  • [BUG REPORT]:

    [BUG REPORT]:

    Your System?

    Ubuntu

    Python Version

    3.8

    HtmlWebShot Version

    latest

    What happened?

    Delay not working at all

    Used Code.

    //tried this
    shot.params = {"--javascript-delay": 5000}
    //and this
    shot.create_pic(html="file.html", delay=5, output="out.jpg", size=(1024,512))
    //none worked?
    

    Error Logs.

    No response

    bug 
    opened by asauce0972 1
Releases(v0.1.0)
Make your master artistic punk avatar through machine learning world famous paintings

Master-art-punk Make your master artistic punk avatar through machine learning world famous paintings. 通过机器学习世界名画制作属于你的大师级艺术朋克头像 Nowadays, NFT is beco

蒋虎成 23 Jan 04, 2022
Create a static HTML/CSS image gallery from a bunch of images.

gallerize Create a static HTML/CSS image gallery from a bunch of images.

Jochen Kupperschmidt 19 Aug 21, 2022
Next-generation of the non-destructive, node-based 2D image graphics editor

Non-destructive, node-based 2D image graphics editor written in Python, focused on simplicity, speed, elegance, and usability

Gimel Studio 238 Dec 30, 2022
Image2scan - a python program that can be applied on an image in order to get a scan of it back

image2scan Purpose image2scan is a python program that can be applied on an image in order to get a scan of it back. For this purpose, it searches for

Kushal Shingote 2 Feb 13, 2022
LabelMe annotation tool source code

LabelMe annotation tool source code Here you will find the source code to install the LabelMe annotation tool on your server. LabelMe is an annotation

MIT CSAIL Computer Vision 1.3k Jan 03, 2023
Visage Differentiation is a GUI application for outlining and labeling the visages in an image.

Visage Differentiation Visage Differentiation is a GUI application for outlining and labeling the visages in an image. The main functionality is provi

Grant Randa 0 Jan 13, 2022
Clip Bing Maps backgound as RGB geotif image using center-point from vector data of a shapefile and Bing Maps zoom

Clip Bing Maps backgound as RGB geotif image using center-point from vector data of a shapefile and Bing Maps zoom. Also, rasterize shapefile vectors as corresponding label image.

Gounari Olympia 2 Nov 22, 2021
👾 Python project to help you convert any image into a pixel art.

👾 Pixel Art Generator Python project to help you convert any image into a pixel art. ⚙️ Developer's Guide Things you need to get started with this co

Atul Anand 6 Dec 14, 2022
A tool to maintain an archive/mirror of your Google Photos library for backup purposes.

Google Photos Archiver Updated Instructions 8/9/2021 Version 2.0.6 Instructions: Download the script (exe or python script listed below) Follow the in

Nick Dawson 116 Jan 03, 2023
Imutils - A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.

imutils A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, and displ

PyImageSearch 4.3k Jan 01, 2023
Avatar Generator Python

This is a simple avatar generator project which uses your webcam to take pictures and saves five different types of your images into your device including the original image.

Faisal Ahmed 3 Jan 23, 2022
Photini - A free, easy to use, digital photograph metadata (Exif, IPTC, XMP) editing application for Linux, Windows and MacOS.

A free, easy to use, digital photograph metadata (Exif, IPTC, XMP) editing application for Linux, Windows and MacOS. "Metadata" is said to mea

Jim Easterbrook 120 Dec 20, 2022
🛹 Turn an SVG into an STL for stencil creation purposes

svg2stl This repository provides a script which takes as input an SVG such as this one: It outputs an STL file like this one: You can also see an inte

Max Halford 3 Dec 29, 2021
Validate arbitrary image uploads from incoming data urls while preserving file integrity but removing EXIF and unwanted artifacts and RCE exploit potential

Validate arbitrary base64-encoded image uploads as incoming data urls while preserving image integrity but removing EXIF and unwanted artifacts and mitigating RCE-exploit potential.

A3R0 1 Jan 10, 2022
Simple Python package to convert an image into a quantized image using a customizable palette

Simple Python package to convert an image into a quantized image using a customizable palette. Resulting image can be displayed by ePaper displays such as Waveshare displays.

Luis Obis 3 Apr 13, 2022
Python framework for creating and scaling up production of vector graphics assets.

Board Game Factory Contributors are welcome here! See the end of readme. This is a vector-graphics framework intended for creating and scaling up prod

Adam Volný 5 Jul 13, 2022
A Blender add-on to create interesting meshes using symmetry

Procedural Symmetries This Blender add-on automates the process of iteratively applying a set of reflection planes to a base mesh. The result will con

1 Dec 29, 2021
API to help generating QR-code for ZATCA's e-invoice known as Fatoora with any programming language

You can try it @ api-fatoora api-fatoora API to help generating QR-code for ZATCA's e-invoice known as Fatoora with any programming language Disclaime

نافع الهلالي 12 Oct 05, 2022
Docbarcodes extracts 1D and 2D barcodes from scanned PDF documents or images. It can be used to automate extraction and processing of all kind of documents.

Intro Barcodes are being used in many documents or forms to enable machine reading capabilities and reduce manual processing effort. Simple 1D barcode

Arlind Nocaj 3 Jun 18, 2022
An open source image editor which can manipulate an image in many ways!

Image Editor - An open source image editor which can manipulate an image in many ways! If you need any more modes in repo or I

TroJanzHEX 44 Nov 17, 2022