init
This commit is contained in:
commit
d38b9f1ab0
6 changed files with 89 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
**/mutations
|
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Assets
|
||||
|
||||
## Saluco
|
||||
|
||||

|
||||

|
||||
|
||||
### Derivatives
|
||||
Created with `./scale ./logos/saluco`
|
||||
|
||||
> If you see nothing here, the derivatives weren't generated.
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
BIN
logos/saluco/saluco-black.png
Normal file
BIN
logos/saluco/saluco-black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
BIN
logos/saluco/saluco-white.png
Normal file
BIN
logos/saluco/saluco-white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
logos/saluco/saluco.xcf
Normal file
BIN
logos/saluco/saluco.xcf
Normal file
Binary file not shown.
65
scale
Executable file
65
scale
Executable file
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Default heights to scale images to
|
||||
DEFAULT_HEIGHTS=(35 70 140 280)
|
||||
|
||||
# Function to resize image while maintaining aspect ratio
|
||||
resize_image() {
|
||||
local input_file="$1"
|
||||
local height="$2"
|
||||
local filename=$(basename "$input_file")
|
||||
local dirname=$(dirname "$input_file")
|
||||
local extension="${filename##*.}"
|
||||
local name="${filename%.*}"
|
||||
|
||||
echo "$dirname" | grep -q "mutations" && return 1
|
||||
|
||||
# Create the derivatives directory if it doesn't exist
|
||||
local output_dir="${dirname}/mutations/${name}"
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
local output_file="${output_dir}/${name}_${height}.${extension}"
|
||||
|
||||
# Check if the output file already exists
|
||||
if [[ ! -f "$output_file" ]]; then
|
||||
# Use convert (ImageMagick) to resize the image
|
||||
convert "$input_file" -resize "x${height}" "$output_file"
|
||||
echo "Resized $input_file to $output_file"
|
||||
else
|
||||
echo "Skipped $input_file, $output_file already exists"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to process directory recursively
|
||||
process_directory() {
|
||||
local dir="$1"
|
||||
local heights=("${!2}")
|
||||
|
||||
find "$dir" -type d -name "*_derivatives" -prune -o -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -o -iname '*.bmp' \) -print | while read -r file; do
|
||||
for height in "${heights[@]}"; do
|
||||
resize_image "$file" "$height"
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
local target_dir="$1"
|
||||
shift
|
||||
local heights=("$@")
|
||||
|
||||
if [[ -z "$target_dir" ]]; then
|
||||
echo "Usage: $0 <directory> [heights...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ${#heights[@]} -eq 0 ]]; then
|
||||
heights=("${DEFAULT_HEIGHTS[@]}")
|
||||
fi
|
||||
|
||||
process_directory "$target_dir" heights[@]
|
||||
}
|
||||
|
||||
# Call the main function with all script arguments
|
||||
main "$@"
|
||||
|
Loading…
Reference in a new issue