jgivy's profile picture

Published by

published

Category: Web, HTML, Tech

Moving away from Instagram (dot) com and some nerdy stuff

We all know instagram sucks. It's fun for a while but I think there's better ways to interact and share with people. I personally will probably stop posting on instagram in the near future, especially for personal use since they're taking away E2E encryption on May 8th.

Let's make a website!

I technically already have a website on neocities.org but I want this one to be really mine. I'll probably start hosting a website once I move out for university. I'll share this website with the people closest to me and it will be some sort of personal digital photo album.

Nerdy stuff

The actual reason I'm writing this post is because I wanted to share a script I just made. It took me about two hours (including an 1h bathroom-smoke-YouTube break) but that's because I have no clue what I'm doing:

#!/usr/bin/bash

for FILE in $(/bin/ls -l | cut -c1-); do
  if [[ "$FILE" =~ SMALL\.jpg$ ]]; then
    echo "$FILE" is already small, skipping.
  else
    magick "$FILE" -resize 1024x1024\> "$FILE-SMALL.jpg" # 1024x768 = XGA
  fi
done

(Also no AI was used to make this script.)

The point of this script is to resize any JPEG image files within the directory to make them smaller and therefore faster to load. I chose XGA as the resolution for no real reason. I just like the numbers. Furthermore, you might notice that I put 1024x1024 as the resolution, that's because imagemagick fits the image in a box. I want the biggest length to be 1024. If I had just left 1024x768, I could've run the risk of getting a portrait picture resized in such a manner that its height (maximum length) was 768 which is NO BUENO!

To resize the images I used imagemagick (the "magick" you see in the script) since it's small and easy to use.

The script lists the file in the directory and for each entry (each file) it checks if it's a .jpg (i just realized I need to add all the different file extensions whoops) and wether it has a -SMALL appended to the file name, if true (big) then the script does nothing, if false then the script runs the magick command to resize the file, appending -SMALL to the end of the file name.

Alright that's pretty much it. I like writing small scripts and I might share some more in the future. And remember. DO NOT RUN ANY SCRIPTS FROM THE INTERNET IF YOU DON'T KNOW WHAT THEY DO (I once deleted all the files in my /home/ directory) by running a seemingly innocent script from 4chan. You live to learn I guess...


5 Kudos

Comments

Displaying 2 of 2 comments ( View all | Add Comment )

Lexi :P

Lexi :P's profile picture

Man that’s so cool I wish I understood better :,)


Report Comment

porkupyn3

porkupyn3's profile picture

BITSIF CODING LANGUAGE


Report Comment