Skip to content

ClaireCJS/fix_wrong_image_extensions

Repository files navigation

fix_wrong_image_extensions

fix_wrong_image_extensions is a filename fixer that fixes the extension of images saved with wrong/duplicate/no extensions

What "wrong" filenames does it fix, specifically?

It fixes any of these (and not just for JPGs--that's just the example used):

  1. wrong extensions

    • jpg saved as gif (would be renamed back to jpg)
    • gif saved as jpg (would be renamed back to gif)
  2. missing extensions

    • a jpg file named "foo" will be renamed "foo.jpg"
  3. extra extensions

    • a gif named "hello.png.jpg.kitty.gif" would be named "hello.kitty.gif"
  4. repeating extensions

    • changes ".jpg.jpg.jpg" to ".jpg"
    • changes "foo.jpg.bar.jpg" to "foo.bar.jpg"
    • leaves repeating non-image extensions untouched
  5. mis-positioned extensions

    • "foo.jpg.bar" will become "foo.bar.jpg"
  6. annoying minor variances

    • jpgs saved as .jpeg
    • jpgs saved as .jfif
    • jpgs saved as .jpg_large
    • jpgs saved as .jpg_name=orig

Possible thing you might not like

It does this for ALL files that are detected as images via header.

The ONLY ones it skips are .bak files and files ending in ~

This may not be the behavior you like. It wasn't for me, until I added the exception for .bak and ~ files ;)

Installation: Python

Install the appropriate packages:

pip install -r requirements.txt

Get clairecjs_utils:

pip install clairecjs_utils

Actually, that probably won't work, and you'll just have to manually grab the actual clairecjs_utils files from here. This one uses claire_console.py to cycle the foreground color while it is running. Purely for fun. Can easily be removed from the code by searching for "Claire" and commenting out those lines.

Testing

Two unit test files provided to prove it actually works

Contributing: Modification

Feel free to make your own version with neato changes, if you are so inspired.

Those wacky BAT files?

I use TCC -- Take Command Command Line. Technically, my .BAT files are .BTM files. If you want to get the ones I have working, I'd love to help.

License

The Unlicense