aboutsummaryrefslogtreecommitdiff
path: root/stuff/webpkiller
diff options
context:
space:
mode:
authorHannah Isopod <me@bathynomus.xyz>2025-05-10 03:03:58 -0600
committerHannah Isopod <me@bathynomus.xyz>2025-05-10 03:03:58 -0600
commiteb61c1bae2ffad114e17393d91d86fb00d7ac8cd (patch)
tree4f997d73e0843dab760e5d988679a1a86b76f5da /stuff/webpkiller
parent4b9500ddeedbea21f80f41dfe4149cf3bf9be4c3 (diff)
Initialer commit
Just remade the repo because I don't *need* need a comprehensive source history for my personal website and this is easier than getting filter-repo to work good
Diffstat (limited to 'stuff/webpkiller')
-rw-r--r--stuff/webpkiller/webpkiller.cmd31
-rw-r--r--stuff/webpkiller/webpkiller.py27
-rw-r--r--stuff/webpkiller/webpkiller.sh20
-rw-r--r--stuff/webpkiller/webpkiller_win.zipbin0 -> 9383795 bytes
4 files changed, 78 insertions, 0 deletions
diff --git a/stuff/webpkiller/webpkiller.cmd b/stuff/webpkiller/webpkiller.cmd
new file mode 100644
index 0000000..382e048
--- /dev/null
+++ b/stuff/webpkiller/webpkiller.cmd
@@ -0,0 +1,31 @@
+@echo off
+
+::Set variable filepath to the first argument
+SET filepath=%~f1
+
+::Abort if the given file doesn't exist
+IF NOT EXIST "%filepath%" (
+ ECHO %~n0: file not found - %filepath% >&2
+ EXIT /B 1
+)
+
+::Replace all instances of .webp with .png in the filename. kind of banking on the user not putting the extension anywhere else in the file or folder names for this to work properly...
+::I should be finding the last period in the filename and replacing everything AFTER it with the extension I want, but can't figure out how to do that because Windows batch is a nightmare language
+::You can replace this with "SET outfile=%filepath%.png" (no quotes) if that bothers you more than double file extensions
+::You can replace these two file extensions with any two image types you want to do this with
+SET outfile=%filepath:.webp=.png%
+
+::Abort if filename.png already exists
+IF EXIST "%outfile%" (
+ ECHO %~n0: %outfile% already exists. Aborting...
+ EXIT /B 2
+)
+
+::Use ImageMagick's command line tools to generate the converted file
+magick "%filepath%" "%outfile%"
+
+::Delete the original file (optional, this can be removed if for some reason you want to keep the shitty gross webp)
+del "%filepath%"
+
+::Open the new, fixed image like nothing ever happened
+%outfile%
diff --git a/stuff/webpkiller/webpkiller.py b/stuff/webpkiller/webpkiller.py
new file mode 100644
index 0000000..0153ff7
--- /dev/null
+++ b/stuff/webpkiller/webpkiller.py
@@ -0,0 +1,27 @@
+import PIL as pillow
+from PIL import Image
+import subprocess, os, platform, sys
+
+infile = sys.argv[len(sys.argv)-1]
+outfile = infile[:infile.rfind('.')] + ".png"
+
+if(os.path.exists(infile) == False):
+ print("File %s not found. Aborting..." %infile)
+ exit()
+
+if(os.path.exists(outfile)):
+ print("File %s already exists. Aborting..." %outfile)
+ exit()
+
+im = Image.open(infile)
+
+im.save(outfile)
+
+os.remove(infile)
+
+if(platform.system() == 'Darwin'): # macOS
+ subprocess.call(('open', outfile))
+elif(platform.system() == 'Windows'): # Windows
+ os.startfile(outfile)
+else: # linux variants
+ subprocess.call(('xdg-open', outfile)) \ No newline at end of file
diff --git a/stuff/webpkiller/webpkiller.sh b/stuff/webpkiller/webpkiller.sh
new file mode 100644
index 0000000..017fba0
--- /dev/null
+++ b/stuff/webpkiller/webpkiller.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+if [ ! -f "$1" ]; then
+ echo "File $1 does not exist. Aborting..."
+ exit
+fi
+
+suffix=".webp"
+filename=${1%"$suffix"}
+outfile="$filename.png"
+
+if [ -f "$outfile" ]; then
+ echo "File $outfile already exists. Aborting..."
+ notify-send --app-name=webpkiller "File $outfile already exists. Aborting..."
+ exit
+fi
+
+magick $1 $outfile
+rm -rf $1
+
+xdg-open $outfile
diff --git a/stuff/webpkiller/webpkiller_win.zip b/stuff/webpkiller/webpkiller_win.zip
new file mode 100644
index 0000000..5d54054
--- /dev/null
+++ b/stuff/webpkiller/webpkiller_win.zip
Binary files differ