Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Use a Simple Bash Script to Resize Your Images Quickly and Easily

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Use a Simple Bash Script to Resize Your Images Quickly and Easily


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

I just wanted to start out by saying that this is an abridged version of my original published version from March 10, 2021 that you can find on my website here.

When curating the images for my website I was original only using Preview and then sped up my process with ImageMagickยฎ commands through my terminal which I published a post about earlier. I then realized why not go even further and put together a simple bash script to quickly resize, compress, and rename a copy of each of those images before uploading them to my blog. This is what I'm sharing here!

The full iterative process of this including an overview of the script and a detailed view is on my website in my original post so I'll jump ahead and share my final script here.... after linking the script that's part of my public SimplyKyraBlog project here. And here it is!

#!/bin/bash

# Confirm the proper argument was given; otherwise a blank argument would send you to the home directory
if [ $# -ne 1 ]; then
    echo "Please call this script with a single argument giving me the path of the directory you want to run this in. If it has spaces please put it in double quotes."
    exit 1
elif [ ! -e "$1" ]; then 
    echo "Directory doesn't exist. Please pass in a valid directory you want the program to run in for the first argument." 
    exit 1
elif [ ! -d "$1" ]; then 
    echo "That isn't a directory. Please pass in a valid directory for the program to run in."
    exit 1 
fi

echo -e "\nWorking in directory: $1 "
cd "$1"

# Checks to see the condition returned and if failed exits the program
if [ $? -ne 0 ]; then           
    echo "Couldn't access the directory specified. Exiting."
    exit 1
fi

mkdir output
# Checks to see the condition returned and if failed exits the program
if [ $? -ne 0 ]; then
    echo "Couldn't create the temporary directory needed. Exiting"
    exit 1
fi

# Compress all jpg, jpeg, and png images in the folder. The stderror is sent to null in case some image types aren't available.
mogrify -path output -resize 750 -quality 100% -define jpeg:extent=70KB *.JPG 2>/dev/null 
mogrify -path output -resize 750 -quality 100% -define jpeg:extent=70KB *.jpg 2>/dev/null
mogrify -path output -resize 750 -quality 100% -define jpeg:extent=70KB *.PNG 2>/dev/null
mogrify -path output -resize 750 -quality 100% -define jpeg:extent=70KB *.png 2>/dev/null
mogrify -path output -resize 750 -quality 100% -define jpeg:extent=70KB *.jpeg 2>/dev/null
mogrify -path output -resize 750 -quality 100% -define jpeg:extent=70KB *.JPEG 2>/dev/null

# Moves to be with the newly created folders so they can be renamed
cd output

# Removes the Pinterest (wrong size), Instagram (unneeded) images, any images ending with 'original' as that shows there's an updated blurred image for the blog, anything that says to ignore, and any image used in a collage.
find . -name "*original*" -delete
find . -name "*ignore*" -delete
find . -name "*interest*" -delete
find . -name "*nstagram*" -delete
find . -name "collage_*" -delete

# Adds the text compressed_ before all the filenames
find * -exec mv {} "compressed_{}" \;

# Moves all the images up a folder and removes the temporary output folder
mv * .. 
cd .. 
rmdir output

# If there's a Pinterest image it compresses it to the right size and names it the proper wayi
find . -name '*Pinterest*' | while read line; do
     magick convert "$line" -resize 471 -define jpeg:extent=70KB "compressed_${line:2}" 
done

echo -e "All done. Completed successfully.\nHave a great day!\n"

I want to remind you that I show that and detailed view of this script at my SimplyKyra website where this original and longer published version from March 10, 2021 lives.

Hope this can help free up some time for you and you're having a great day!

...



๐Ÿ“Œ Use a Simple Bash Script to Resize Your Images Quickly and Easily


๐Ÿ“ˆ 85.62 Punkte

๐Ÿ“Œ How to resize your images quickly and easily


๐Ÿ“ˆ 54.74 Punkte

๐Ÿ“Œ How to resize your images quickly and easily


๐Ÿ“ˆ 54.74 Punkte

๐Ÿ“Œ Mosaic: a simple window manager to resize and reposition apps on your desktop easily


๐Ÿ“ˆ 43.05 Punkte

๐Ÿ“Œ How to quickly resize images on Mac 2023


๐Ÿ“ˆ 37.75 Punkte

๐Ÿ“Œ Bash Script Include Another Bash Script


๐Ÿ“ˆ 36.61 Punkte

๐Ÿ“Œ Quickly Create App Icons by Resizing Your Main Image With a Bash Script


๐Ÿ“ˆ 34.86 Punkte

๐Ÿ“Œ Do you ever need to quickly and easily parallelize a script? If so, you may be interested in this tool I recently wrote.


๐Ÿ“ˆ 34.09 Punkte

๐Ÿ“Œ Quickly fetch your WiFi password and if needed, generate a QR code of your WiFi to allow phones to easily connect


๐Ÿ“ˆ 33.54 Punkte

๐Ÿ“Œ Wifi-Password - Quickly Fetch Your WiFi Password And If Needed, Generate A QR Code Of Your WiFi To Allow Phones To Easily Connect


๐Ÿ“ˆ 33.54 Punkte

๐Ÿ“Œ Learn SQL Quickly & Join Data Easily, With This Simple Method & Get into 11 New Professions !!!!


๐Ÿ“ˆ 32.77 Punkte

๐Ÿ“Œ niieani/bash-oo-framework: Bash Infinity is a modern boilerplate / framework / standard library for bash


๐Ÿ“ˆ 32.37 Punkte

๐Ÿ“Œ Bash Scripting - BASH Scripts For Heavy Commandline Users [Bash Snippets]


๐Ÿ“ˆ 32.37 Punkte

๐Ÿ“Œ Bash Scripting - BASH Scripts For Heavy Commandline Users [Bash Snippets]


๐Ÿ“ˆ 32.37 Punkte

๐Ÿ“Œ Back to bash: Inception, running bash inside bash


๐Ÿ“ˆ 32.37 Punkte

๐Ÿ“Œ MiniTool ShadowMaker โ€“ Backup and Safeguard Your Important Data Quickly and Easily


๐Ÿ“ˆ 31.83 Punkte

๐Ÿ“Œ I wrote a bash script for pacman to easily downgrade a package and it's dependencies to any date


๐Ÿ“ˆ 31.8 Punkte

๐Ÿ“Œ Simple Bash Prompt โ€“ a fast, pretty, extendable and pure bash prompt


๐Ÿ“ˆ 31.33 Punkte

๐Ÿ“Œ Learn how to quickly and easily use with mail-merge in Gmail ๐Ÿ“ง #Shorts


๐Ÿ“ˆ 31.18 Punkte

๐Ÿ“Œ hackerEnv - An Automation Tool That Quickly And Easily Sweep IPs And Scan Ports, Vulnerabilities And Exploit Them


๐Ÿ“ˆ 30.13 Punkte

๐Ÿ“Œ How to connect your laptop to a TV -- quickly and easily


๐Ÿ“ˆ 30.06 Punkte

๐Ÿ“Œ Check Your Apple Card Application Quickly and Easily


๐Ÿ“ˆ 30.06 Punkte

๐Ÿ“Œ Made a bash script for easily executing the Docker image security scanner Clair


๐Ÿ“ˆ 30.03 Punkte

๐Ÿ“Œ Simple BASH script for Cleaning Temporary Files and Cache on Debian, Ubuntu, Linux Mint and Elementary OS.


๐Ÿ“ˆ 29.83 Punkte

๐Ÿ“Œ How to improve your bash/sh shell script with ShellCheck lint script analysis tool


๐Ÿ“ˆ 29.3 Punkte

๐Ÿ“Œ What is a Bash Script? [13 of 20] | Bash for Beginners


๐Ÿ“ˆ 29.09 Punkte

๐Ÿ“Œ Bash add pause prompt in a shell script ( bash pause command )


๐Ÿ“ˆ 29.09 Punkte

๐Ÿ“Œ MobileIron and Teamwire to help orgs quickly and easily establish a foundation for secure communications


๐Ÿ“ˆ 28.35 Punkte

๐Ÿ“Œ McAfee Announces MVISION Marketplace and MVISION API to Enable Organizations to Quickly and Easily Adapt to Security Gaps


๐Ÿ“ˆ 28.35 Punkte

๐Ÿ“Œ How to Use Redirection and Pipelines in Bash [11 of 20] | Bash for Beginners


๐Ÿ“ˆ 27.97 Punkte











matomo