Skip to content

Instantly share code, notes, and snippets.

@greg-randall
greg-randall / gist:2dcd79a769a3d64ad3b3f0de81b9e6bb
Created September 19, 2019 16:48
Remove all metadata from a folder of JPGS
for i in *.jpg; do echo "Processing $i"; exiftool -all= "$i"; done
from: http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Remove-EXIF-Metadata-from-Photos-with-exiftool
@greg-randall
greg-randall / gist:6538fcd464023723c54dbb87519666a9
Created November 11, 2019 20:20
Create a blank video with audio, upload to youtube, download the auto generated captions, and then make a transcript. Useful for uploading to youtube to get a free transcript.
Step 1:
ffmpeg -r 1 -loop 1 -i blank_1920x1080.png -i input.wav -r 1 -shortest output.mp4
Step 2:
Upload output.mp4 to youtube. Wait an hour or so for the automatic captions to generate
Step 3:
youtube-dl --write-sub --sub-lang en --skip-download ____Youtube URL from Previous Step____
Step 4:
@greg-randall
greg-randall / avg.py
Last active May 22, 2020 03:32
This is basically a moving average for timelapse images. Make sure you have ImageMagick installed.
#Toss this in a directory of timelapse photos, make sure your files are ordered somehow
#(I've been using unix timestamp for my files), and run it. It'll create a folder called
#'equalized' and it will equalize exposure of all the images, and then it will it will
#average the first 12 images to create output image 1, then it'll average images 2-13
#to create output image 2, and so on until all the images in the folder have been
#averaged. You can change the number of images to average by changing #the average
#variable. Do note, large numbers of images averaged will take _forever_.
import os
from os import path
@greg-randall
greg-randall / gist:00cc2fb7e1650499e2be20ede5db1b67
Created October 13, 2020 13:52
Strip strip audio from a whole folder of video. Very useful for b-roll shoots.
mkdir no-audio; for f in *.MP4; do ffmpeg -i "$f" -an -c:v copy no-audio/$f; done
@greg-randall
greg-randall / pano2vr_spin_generator.php
Created March 19, 2021 19:34
For generating spinning videos from spherical panoramic images using pano2vr. Sample: https://www.youtube.com/watch?v=l_VrEJUUh64
<pre><?php
/*
For generating spinning videos from spherical panos using pano2vr:
https://www.youtube.com/watch?v=l_VrEJUUh64
Fill out the config below.
Run the code, copy and paste the output into a file named "spin.p2vr" or similar.
Make sure your input image is in the same location as your spin.p2vr file.
Open the spin.p2vr file and then hit 'create all' at the bottom right.
@greg-randall
greg-randall / face_mv.py
Last active March 22, 2021 20:54
Quick and dirty way to sort photos into ones that contain a face or don't contain a face using Imagga.
import os
import re
def get_face(img_name):
#find your imagga curl user info on your account
#saves face data as a json
command = f"curl -s --user \"_________imagga-user-code__________\" -F \"image=@{img_name}\" \"https://api.imagga.com/v2/faces/detections\" > {img_name}.json"
os.system(command)
@greg-randall
greg-randall / compress.sh
Last active September 29, 2021 16:59
Compresses a JPEG both lossy and lossless and then strips the metadata. Uses MozJpeg, JpegTran, ExifTool, and Genius to compress and report some data.
#!/bin/bash
#to compress a folder:
#for i in *;do ./compress.sh "$i";done
new_file_name=$(sed 's/ /_/g' <<< "${1%.*}_c.jpg")
cjpeg "$1" | jpegtran -o | exiftool - -all= > "$new_file_name"
before_size=$(wc -c "$1" | awk '{print $1}')
@greg-randall
greg-randall / index.php
Last active July 1, 2025 14:23
HTML Cleaner. Paste dirty html into a field, and it removes nearly all HTML attributes (except the ones you want -- src, href, alt, and a couple others), and formats. Using proper DOMDocument PHP parser.
<?php
/*
Note that the cleaner sends the html to DirtyMarkup for formatting.
Example input:
<div class=WordSection1>
<p class=MsoNormal align=center style='text-align:center'><span
style='font-size:16.0pt;line-height:107%;font-family:"Abadi Extra Light",sans-serif'>Test
Clean<o:p></o:p></span></p>
@greg-randall
greg-randall / index.php
Last active July 23, 2021 15:33
Title Case converter for WordPress post exports.
<?php
/*
Takes a Wordpress Post export and changes the case of the words in the <title> tag to title-case.
This will print out a list of titles at the top with the title case and then the original case, so
you can check over and make sure that you don't need to add any special cases:
Add acronyms or words with non-standard capitalization to the array $caps_words. (note, add spaces
around the word/phrase i.e. ' GitHub '.
To update existing posts requires a temporary addition to your functions file --
@greg-randall
greg-randall / gist:b339995a6ba3c4cf8e04ddb392cb8499
Last active June 13, 2024 16:37
Generate QR Code for URL
# --background=00000000 makes a transparent background, to make it easier for placement in other materials
qrencode -s 60 -l H --background=00000000 -o "output.png" "https://www.asdf.com/querty"
pngcrush output.png output_c.png