I thought I would share 2 shell scripts that I've found useful, the first one allows me to to use my DSLR camera as a webcam and the second one allows me to batch resize and optimize images
Using DSLR as webcam
#!/bin/bash modprobe v4l2loopback exclusive_caps=1 max_buffers=2 gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420 -threads 0 -f v4l2 /dev/video0
Leave this running and the device should be accessible from your videoconferencing software of choice or web browser webRTC app
Here's a list of gphoto2's supported cameras
Batch resizing, compressing and renaming photos
For this one there's a bit of a background, our story begins when I was trying to get in the 512kbclub. A big part of my blog's home page reduction was related to compressing images, at the time a web service was suggested to me: shortpixel but being the nerd I am I thought:
"There should be a way to do this locally on all the pictures in a directory"-me
So I started looking online and did a bit pf patchwork to create a bash script that served this purpose.
I also plan to use this for my Nextcloud instance in my Yunohost install because I've noticed that I've been trying to share links to albums full of DSLR ORIGINAL SIZED IMAGES *facepalms* (something ridiculous like 5000 pixels wide). No wonder my folks kept complaining that their cellphones took forever to load the images...
#!/bin/sh mkdir -p compressed_images mkdir -p resized_images for file in ./*.jpg ./*.jpeg ./*.JPG; do echo "resizing and optimizing $file ..." convert "$file" \ -resize '1900x1080>' \ "./resized_images/$file" jpegoptim "./resized_images/$file" \ -d './compressed_images' \ --max 65 \ --all-progressive \ -p done echo "renaming pictures according to creation date..." for i in ./compressed_images/*; do jhead -n%Y%m%d-%H%M%S $i done echo "deleting transient directory..." rm -rf resized_images echo "done!"
The process is quite simple, navigate to a directory containing the pictures, run the script and it will generate a directory with the compressed pictures, I'm also renaming them from creation date contained in exif data for organization purposes.
This is actually the first time I try to make one of these so I may have some errors or possible improvements, all constructive feedback is welcome.
Day 47 of my 2020's #100DaysToOffload