Code Monkey home page Code Monkey logo

htmi's Introduction

Image to HTML Converter and Viewer

This project consists of two Python scripts that allow you to convert an image file (PNG or JPEG) to an HTML file, where each pixel of the image is represented as a table cell with corresponding colors. It also provides a PyQt5-based viewer to display the generated HTML file.

Prerequisites

  • Python 3.x
  • Required Python packages: Pillow, PyQt5, tkinter

You can install the required packages using pip:

pip install pillow PyQt5

Usage

Step 1: Convert Image to HTML

  1. Run the convert.py script using the following command:
python convert.py
  1. Enter the path of the image file you want to convert when prompted.
  2. The script will generate an HTML file named output.html in the same directory as the script, representing the image in HTML format.

Step 2: View HTML as Image

  1. Run the viewimg.py script using the following command:
python viewimg.py
  1. Use the file dialog to select the output.html file generated in Step 1.

  2. A PyQt5 window titled "HTML Viewer" will open, displaying the image rendered from the HTML file.

Customization

  • Image and HTML file names: You can modify the variables in the convert.py script to specify the desired file names for the input image and output HTML file.

  • Styling: The generated HTML file uses inline styling to set the background color of each table cell. You can modify the CSS styles in the convert.py script to customize the appearance of the rendered image.

Limitations

  • Supported image formats: The scripts support PNG and JPEG image formats. Ensure that the image file you provide is in either of these formats.

  • Large image files: The generated HTML file can become large in size for high-resolution or large-sized images, which may impact the rendering performance in the PyQt5 window.

License

This project is licensed under the MIT LICENSE.

htmi's People

Contributors

omgrod avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.