A simple script for formatting Photoshop HTML generated from image slicing
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.
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 fix.py -f some-html-file-1942.html -d yourdomainhere.ca
The script takes two arguments,
-f (file) and
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
fix.py is in your
/home/ directory, and your HTML file is located in
~/Downloads/eblasts, you would navigate to
~/ and run
python3 fix.py --file ~/Downloads/eblasts/some-html-file-1942.html --domain yourdomainhere.ca. The output file will be generated in the same directory as the HTML file input.
You can also move
fix.py 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,
<img>elements get the correct style tags added to them.
srcattributes will be edited to use the right domain/path for the FTP (
- 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.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size slicefix-jonathandannel-3.7.10.tar.gz (3.9 kB)||File type Source||Python version None||Upload date||Hashes View hashes|
Hashes for slicefix-jonathandannel-3.7.10.tar.gz