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)
Repair broken bookmarks to referenced files in Apple Photos

Repair Apple Photos Bookmarks Work in progress to repair file location bookmarks in Apple Photos. Background Starting in macOS 10.15/Catalina, photos

Rhet Turnbull 10 Nov 03, 2022
Anime2Gif - an algorithm that detects scenes in a video and generates gifs from it

Anime2Gif Anime2Gif is an algorithm that detects scenes in a video and generates gifs from it. How to use To use it, first, you'll need to install it'

1 Dec 09, 2021
Python avatar generator for absolute nerds

pagan Welcome to the Python Avatar Generator for Absolute Nerds. Current version: 0.4.3 View the change history here. Remember those good old days whe

David Bothe 280 Dec 16, 2022
kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns

kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns. The library builds on the

pyxem 53 Dec 29, 2022
Pixel Brush Processing Unit

Pixel Brush Processing Unit The Pixel Brush Processing Unit (PBPU for short) is a simple 4-Bit CPU I designed in Logisim while I was still in school a

Pixel Brush 2 Nov 03, 2022
CropImage is a simple toolkit for image cropping, detecting and cropping main body from pictures.

CropImage is a simple toolkit for image cropping, detecting and cropping main body from pictures. Support face and saliency detection.

Haofan Wang 15 Dec 22, 2022
Simple to use image handler for python sqlite3.

SQLite Image Handler Simple to use image handler for python sqlite3. Functions Function Name Parameters Returns init databasePath : str tableName : st

Mustafa Ozan Çetin 7 Sep 16, 2022
Conversion of Image, video, text into ASCII format

asciju Python package that converts image to ascii Free software: MIT license

Aju Tamang 11 Aug 22, 2022
An executor that performs standard pre-processing and normalization on images.

An executor that performs standard pre-processing and normalization on images.

Jina AI 6 Jun 30, 2022
A not exist person image generator python module

A not exist person image generator python module

Fayas Noushad 2 Dec 03, 2021
Bot by image recognition simulating (random) human clicks

bbbot22 bot por reconhecimento de imagem simulando cliques humanos (aleatórios) inb4: sim, esse é basicamente o mesmo bot de 2021 porque a Globo não t

Yuri 2 Apr 05, 2022
Convert photos to paintings with python

Convert-photos-to-paintings Before the changes After the changes Before the changes After the changes This code is written in the Python programming l

Amir Hussein Sharifnezhad 3 May 31, 2022
Extract the temperature data of each wire from the thermal imager raw data.

Wire-Tempurature-Detection Extract the temperature data of each wire from the thermal imager raw data. The motivation of this computer vision project

JohanAckerman 1 Nov 03, 2021
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
ImageStrike是一款用于CTF中图片隐写的综合利用工具

🎈 简介 ImageStrike是一款使用PyQT5开发,用于CTF中图片隐写的综合利用工具

zR00t1 133 Dec 27, 2022
Fast Image Retrieval (FIRe) is an open source image retrieval project

Fast Image Retrieval (FIRe) is an open source image retrieval project release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This project implements most of the major bi

CISiP Lab 39 Nov 25, 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
Craft PNG files that appear completely different in Apple software

Ambiguous PNG Packer Craft PNG files that appear completely different in Apple software

David Buchanan 1k Dec 29, 2022
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
A pure python implementation of the GIMP XCF image format. Use this to interact with GIMP image formats

Pure Python implementation of the GIMP image formats (.xcf projects as well as brushes, patterns, etc)

FHPyhtonUtils 8 Dec 30, 2022