Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 2.63 KB

README.md

File metadata and controls

74 lines (55 loc) · 2.63 KB

Screenshot with QR Code Generator -- url to image(png)

This repository provides a Go program that captures a screenshot of a webpage, generates a QR code for the same URL, and overlays the QR code and the URL text on the screenshot. The final image is saved as a PNG file.

Table of Contents

Introduction

The goal of this project is to demonstrate how to use Go with chromedp to automate web browsing and screenshot capture. Additionally, it uses the go-qrcode library to generate a QR code for the webpage URL and overlays both the QR code and the URL text on the captured screenshot.

Features

  • Capture a screenshot of a webpage using headless Chrome.
  • Generate a QR code for a specified URL.
  • Overlay the QR code and URL text on the screenshot.
  • Save the final composite image as a PNG file.

Requirements

To run this program, you will need:

  • Go 1.16 or later
  • Headless Chrome
  • Fonts that support Truetype, like DejaVu Sans or any other Truetype font.
  • The following Go packages:
    • github.com/chromedp/chromedp
    • github.com/golang/freetype
    • github.com/golang/freetype/truetype
    • github.com/skip2/go-qrcode
    • golang.org/x/image/font

Installation

  1. Install Go: Ensure you have Go installed on your machine. You can download it from the official Go website.

  2. Install Headless Chrome: If you haven't installed Chrome or Chromium yet, you can download it from here or use your package manager.

  3. Get the required Go packages: Run the following command to install the necessary Go packages:

    go get -u github.com/chromedp/chromedp
    go get -u github.com/golang/freetype
    go get -u github.com/skip2/go-qrcode
    go get -u golang.org/x/image/font
  4. Clone the repository:

  git clone https://github.com/logerror/url2img.git
  cd url2img
  1. Build the program:
  go build -o url2img main.go

Usage

Run the compiled binary with:

./url2img <Url> <Image Path: eg: screenshot_with_qrcode.png>

example:  ./url2img https://logerror.github.io screenshot_with_qrcode.png

The program will capture a screenshot of the specified URL, generate a QR code, overlay the QR code and the URL text on the screenshot, and save the final image as screenshot_with_qrcode.png.