mirror of
https://github.com/peter-tanner/peter-tanner.github.io.git
synced 2024-11-30 03:50:18 +08:00
Updated tools scripts, resize preview images to be smaller.
This commit is contained in:
parent
d26065bcc3
commit
1380471ebc
|
@ -4,7 +4,7 @@ author: peter
|
|||
date: 2023-08-06 21:45:13 +0800
|
||||
categories: [Electronics] # Blogging | Electronics | Programming | Mechanical
|
||||
tags: [electronics, rf, oscilloscope, spectrum analyzer, hack] # systems | embedded | rf | microwave | electronics | solidworks | automation
|
||||
image: /assets/img/2023-08-06-HP-8560A-spectrum/IMG20230801205713.jpg
|
||||
image: /assets/img/2023-08-06-HP-8560A-spectrum/preview.png
|
||||
---
|
||||
|
||||
I just bought a Hitachi VC-6025 oscilloscope from my Singapore trip for 85 SGD. It's a good deal, since there is not a lot of second-hand electronics auctions on Ebay Australia, and the shipping costs from overseas or even interstate make it not very economical.
|
||||
|
|
|
@ -4,7 +4,7 @@ author: peter
|
|||
date: 2023-08-09 19:41:27 +0800
|
||||
categories: [Electronics] # Blogging | Electronics | Programming | Mechanical
|
||||
tags: [rf, microwave, electronics] # systems | embedded | rf | microwave | electronics | solidworks | automation
|
||||
image: /assets/img/2023-08-09-Aliexpress-DC-block/IMG20230809200758.jpg
|
||||
image: /assets/img/2023-08-09-Aliexpress-DC-block/preview.png
|
||||
---
|
||||
|
||||
I recently purchased [this DC block](https://www.aliexpress.com/item/1005002575850555.html) from Aliexpress to protect our HP 8560A spectrum analyzer. I did some basic tests on the DC block and it looks good for the price. These N type DC blocks seem to be less common and twice as expensive than the SMA type, but I wanted to avoid using SMA hardware for my setup.
|
||||
|
|
|
@ -4,7 +4,7 @@ author: peter
|
|||
date: 2024-02-15 16:41:46 +0800
|
||||
categories: [Blogging, Electronics] # Blogging | Electronics | Programming | Mechanical
|
||||
tags: [electronics, solidworks] # systems | embedded | rf | microwave | electronics | solidworks | automation
|
||||
image: /assets/img/2024-02-15-Altium-to-3d-GLTF/website.png
|
||||
image: /assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png
|
||||
---
|
||||
|
||||
As part of the [Neptunium flight computer](https://www.petertanner.dev/neptunium/), I wanted to create a proper webpage to showcase the flight computer. This will also be a landing page for people who want to use the wasm powered Neptunium Explorer, which will allow users to analyze flight data in the browser. At the center of this webpage I want to show an interactive 3d model of the flight computer
|
||||
|
|
|
@ -4,7 +4,7 @@ author: peter
|
|||
date: 2024-02-24 14:06:00 +0800
|
||||
categories: [Electronics] # Blogging | Electronics | Programming | Mechanical
|
||||
tags: [electronics, bus] # systems | embedded | rf | microwave | electronics | solidworks | automation
|
||||
image: /assets/img/2024-02-24-Inside-a-bus-USB-cha/usb-charger-bus-highres.jpg
|
||||
image: /assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png
|
||||
---
|
||||
|
||||
Random post, on the bus I saw one of those wall-mounted USB chargers with the plastic cover already removed (I did not remove it). This is what the PCB inside of it looks like.
|
||||
|
|
BIN
assets/img/2023-08-06-HP-8560A-spectrum/preview.png
Normal file
BIN
assets/img/2023-08-06-HP-8560A-spectrum/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 315 KiB |
BIN
assets/img/2023-08-09-Aliexpress-DC-block/preview.png
Normal file
BIN
assets/img/2023-08-09-Aliexpress-DC-block/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1011 KiB |
BIN
assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png
Normal file
BIN
assets/img/2024-02-15-Altium-to-3d-GLTF/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 KiB |
BIN
assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png
Normal file
BIN
assets/img/2024-02-24-Inside-a-bus-USB-cha/preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 324 KiB |
44
generate-preview-images.sh
Executable file
44
generate-preview-images.sh
Executable file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Function to convert JPG/JPEG to PNG
|
||||
convert_to_png() {
|
||||
local file="$1"
|
||||
local filename="${file%.*}" # Remove extension
|
||||
local new_file="${filename}.png"
|
||||
|
||||
echo "Converting $file to PNG..."
|
||||
convert "$file" "$new_file"
|
||||
echo "Converted $file to PNG: $new_file"
|
||||
|
||||
# Update file variable to the new PNG file
|
||||
file="$new_file"
|
||||
}
|
||||
|
||||
# Loop through all preview.jpg and preview.jpeg files in assets/img/<folder> directories
|
||||
for file in assets/img/*/{preview.jpg,preview.jpeg}; do
|
||||
if [ -f "$file" ]; then
|
||||
# Convert JPG/JPEG to PNG
|
||||
convert_to_png "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# Loop through all preview.png files in assets/img/<folder> directories
|
||||
for file in assets/img/*/preview.png; do
|
||||
if [ -f "$file" ]; then
|
||||
# Get current dimensions
|
||||
current_width=$(identify -format "%w" "$file")
|
||||
current_height=$(identify -format "%h" "$file")
|
||||
|
||||
# Calculate new dimensions, keeping aspect ratio
|
||||
new_width=1200
|
||||
new_height=630
|
||||
if [ "$current_width" -gt "$new_width" ] || [ "$current_height" -gt "$new_height" ]; then
|
||||
# Resize only if current dimensions exceed the new dimensions
|
||||
convert "$file" -resize "${new_width}x${new_height}>" "$file"
|
||||
echo "Resized $file"
|
||||
# else
|
||||
# echo "No need to resize $file"
|
||||
fi
|
||||
fi
|
||||
done
|
25
post.sh
25
post.sh
|
@ -7,18 +7,6 @@ sanitize_title() {
|
|||
echo "$sanitized_title" | tr ' ' '-'
|
||||
}
|
||||
|
||||
# Function to generate the front matter with the current date
|
||||
generate_front_matter() {
|
||||
current_date=$(date +'%Y-%m-%d %H:%M:%S %z')
|
||||
echo "---"
|
||||
echo "title: $1"
|
||||
echo "author: peter"
|
||||
echo "date: $current_date"
|
||||
echo "categories: [Blogging] # Blogging | Electronics | Programming | Mechanical"
|
||||
echo "tags: [getting started] # systems | embedded | rf | microwave | electronics | solidworks | automation"
|
||||
echo "---"
|
||||
}
|
||||
|
||||
# Prompt the user for a title
|
||||
read -e -p "Enter the title: " user_title
|
||||
|
||||
|
@ -30,6 +18,19 @@ current_date=$(date +'%Y-%m-%d')
|
|||
filename="${current_date}-${sanitized_title}"
|
||||
filepath="_posts/${filename}.md"
|
||||
|
||||
# Function to generate the front matter with the current date
|
||||
generate_front_matter() {
|
||||
current_date=$(date +'%Y-%m-%d %H:%M:%S %z')
|
||||
echo "---"
|
||||
echo "title: $1"
|
||||
echo "author: peter"
|
||||
echo "date: $current_date"
|
||||
echo "categories: [Blogging] # Blogging | Electronics | Programming | Mechanical"
|
||||
echo "tags: [getting started] # systems | embedded | rf | microwave | electronics | solidworks | automation"
|
||||
echo "# image: assets/img/${filename:0:31}/preview.png"
|
||||
echo "---"
|
||||
}
|
||||
|
||||
# Check if the file already exists
|
||||
if [ -e "$filepath" ]; then
|
||||
echo "A file with the name '$filename' already exists in the '_posts' subdirectory."
|
||||
|
|
Loading…
Reference in New Issue
Block a user