Skip to main content

A simple script for formatting Photoshop HTML generated from image slicing

Project description

A simple Python script for editing Photoshop slice generated HTML for use with e-blasts.


  • Python 3. Run which python3; If not found, install with Homebrew, apt, or whatever else you use. Once it is installed, make sure the shebang path at the start of the script (ex: #!/usr/bin/python3) matches where your Python 3 is installed.

Use pip 3 to install dependencies:

pip3 will be installed with your Python 3 install.

  • Run pip3 install -r requirements.txt. This will install the bs4 and datetime packages. You can also install them manually, if you like. The script will not work if you skip this step.


python3 -f some-html-file-1942.html -d

The script takes two arguments, -f (file) and -d (domain).


The .html file you want to fix. If you're running the script in the same directory as the HTML file, then all you have to do is type in/paste the file name. You can also specify a path (this is better)

For example, if your is in your ~/ or /home/ directory, and your HTML file is located in ~/Downloads/eblasts, you would navigate to ~/ and run python3 --file ~/Downloads/eblasts/some-html-file-1942.html --domain The output file will be generated in the same directory as the HTML file input.

You can also move into whatever directory contains the HTML file and run it from there, so you don't have to type out the path to the file.


The domain (without http://) where the images in the HTML are hosted. For example,


  • All <img> elements get the correct style tags added to them.
  • All <img> src attributes will be edited to use the right domain/path for the FTP (http:// and /eblasts/).
  • Center element, SEO text div, and other pre-table and post-table content is added.
  • The original HTML file will be untouched. A new file will be generated, named the same as the original file but with an underscore and timestamp (seconds) added to it. The new file will be generated in the same directory as the original HTML file.


  • Depending on usage, I could work a bit more on customizing where the file is saved or generated.
  • Add batch file support, more CLI args.


You'll still need to edit the SEO text and client address text manually.

Feel free to contribute more features if you like. It's simple now, but it could end up being pretty useful in the future.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slicefix-jonathandannel-3.7.10.tar.gz (3.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page