Skip to content

Script to generate base64-encoded image strings to be used as placeholder images on websites for multiple images at once.

Notifications You must be signed in to change notification settings

vik-ma/generate-placeholder-image-base64-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate Placeholder Image Base64 Data String

This is a simple Python script to generate multiple base64-encoded image strings to be used as placeholder images that appears before the images on a website are fully loaded.

The script will resize, optimize and generate a base64 string for every image in the 'input' folder and then write the base64 data string for every image in an 'output.txt' file.

The format of the outputted strings will look like this: 'data:image/jpeg;base64,' followed by the generated base64 string.

Requirements

The script only requires the Pillow package to run.

How To Use

  1. Create a folder in the same directory as main.py named 'input'.
    (The name of the folder can be changed with the INPUT_FOLDER_DIR variable inside 'main.py')
  2. Place all the images you want to generate base64 data string for inside the 'input' folder.
  3. Edit the 'OUTPUT_IMAGE_WIDTH', 'OUTPUT_IMAGE_HEIGHT' and 'OUTPUT_IMAGE_QUALITY' variables inside 'main.py' to your liking.
    (It is recommended to keep the width and height below 10)
    (Image Quality must range between 1 to 95, where 1 is the lowest quality and 95 the highest)
  4. Run 'main.py' and check the generated 'output.txt' file for every image's base64 string.

About

Script to generate base64-encoded image strings to be used as placeholder images on websites for multiple images at once.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages