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)
a lite weight photo editor written in python for day to day photo editing!

GNU-PhotoShop A lite weight Photo editing Program (currently CLI only) written in python3 for day to day photo editing. Disclaimer : Currently we don'

Kunal Sharma 5 May 30, 2022
Archive of the image generator stuff from my API

alex_api_archive Archive of the image generator stuff from my API FAQ Q: Why? A: Because I am removing these components from the API Q: How do I run i

AlexFlipnote 26 Nov 17, 2022
QR-Generator - An awesome QR Generator to create or customize your QR's

QR Generator An awesome QR Generator to create or customize your QR's! Table of

Tristán 1 Jan 28, 2022
clesperanto is a graphical user interface for GPU-accelerated image processing.

clesperanto is a graphical user interface for a multi-platform multi-language framework for GPU-accelerated image processing. It is based on napari and the pyclesperanto-prototype.

1 Jan 02, 2022
An example which streams RGB-D images over spout.

Spout RGB-D Example An example which streams RGB-D images over spout with visiongraph. Due to the spout dependency this currently only works on Window

Florian Bruggisser 4 Nov 14, 2022
Pnuemonia Normal detection by using XRay images.

Pnuemonia Normal detection by using XRay images. Got image datas from kaggle(link is given in sources.txt file) also normal xray images from other site (also link is given) in order to avoid data dis

Zarina 1 Feb 28, 2022
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.

Tom 30 Dec 24, 2022
Image histogram remapping

Hmap An image histogram remapping script written in Python 2.7 by Anthony Kesich and Ross Goodwin. Changes source image so that source image's histogr

Ross Goodwin 199 Nov 19, 2022
Samila is a generative art generator written in Python

Samila is a generative art generator written in Python, Samila let's you create arts based on many thousand points. The position of every single point is calculated by a formula, which has random par

Sepand Haghighi 947 Dec 30, 2022
Image Processing - Make noise images clean

影像處理-影像降躁化(去躁化) (Image Processing - Make Noise Images Clean) 得力於電腦效能的大幅提升以及GPU的平行運算架構,讓我們能夠更快速且有效地訓練AI,並將AI技術應用於不同領域。本篇將帶給大家的是 「將深度學習應用於影像處理中的影像降躁化 」,

2 Aug 04, 2022
HTML2Image is a lightweight Python package that acts as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

A package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.

176 Jan 01, 2023
Bringing vtk.js into Dash and Python

Dash VTK Dash VTK lets you integrate the vtk.js visualization pipeline directly into your Dash app. It is powered by react-vtk-js. Docs Demo Explorer

Plotly 88 Nov 29, 2022
Python QR Code image generator

Pure python QR Code generator Generate QR codes. For a standard install (which will include pillow for generating images), run: pip install qrcode[pil

Lincoln Loop 3.5k Dec 31, 2022
Dynamic image server for web and print

Quru Image Server - dynamic imaging for web and print QIS is a high performance web server for creating and delivering dynamic images. It is ideal for

Quru 84 Jan 03, 2023
Instagram-like image filters.

PyGram Instagram-like image filters. Usage First, import the client: from filters import * Instanciate a filter and apply it: f = Nashville("image.jp

Ajay Kumar Nagaraj 0 Oct 18, 2022
Png-to-stl - Converts PNG and text to SVG, and then extrudes that based on parameters

have ansible installed locally run ansible-playbook setup_application.yml this sets up directories, installs system packages, and sets up python envir

1 Jan 03, 2022
Cat avatars for adult independent users

Cat avatars for adult independent users Samples (Natasha, wake up!) Usage Check values from https://shantichat.github.io/avacats/index.json: { "sizes"

4 Nov 05, 2021
Semi-hash-based Image Generator

pixel-planet Semi-hash-based Image Generator Utilizable for NFTs Generation Process Input is salted and hashed Colors (background, planet, stars) are

Bill Ni 3 Sep 01, 2022
Python script to generate vector graphics of an oriented lattice unit cell

unitcell Python script to generate vector graphics of an oriented lattice unit cell Examples unitcell --type hexagonal --eulers 12 23 34 --axes --crys

Philip Eisenlohr 2 Dec 10, 2021
This projects aim is to simulate flowers(Gerbera Daisy) phyllotaxis.

phyllotaxis This projects aim is to simulate flowers(Gerbera Daisy) phyllotaxis. Take a look at the arrangement of this flower's seeds, this project's

amirsalar 3 Dec 10, 2021