Inspired by Matt Parker's YouTube video where he showed how image pixels can be expressed as Excel cells.
Description: This is a simple program that takes a user defined image file, optionally shrinks it, and then saves it in an Excel file at the same location of the original image's location.
Features:
- User supplied image (.jpg or .png files) is converted from RGB to HEX pixels.
- Individual cells of Excel sheet are treated as pixels of the image, and openpyxl.styles.PatternFill is used to color these cells according to the values of pixel colors.
- Optinally, user can resize (shrink or expand) the image before exporting it to excel file as well.
- Resulting Excel file is saved at the same location as original file.
Imports: Functions imports the following libraries. So ensure they are installed before using them.
import os
import PIL
import openpyxl
Usage:
from img2xl import img2xl
# Manual Inputs: Only the name of the image path
img_src = r'assets/dog.jpg'
# Calling functions from img2xl
img2xl(img_src, True, 0.2)