feat(images): unify image resize and PNG conversion scripts

feat(images): consolidate resize automation workflow

- Merge automatic and manual resize scripts
- Detect portrait and landscape orientation automatically
- Resize portrait images to x1080
- Resize landscape images to 1920px width
- Support user-defined ImageMagick resize arguments
- Convert JPG/JPEG files to PNG format
- Create output directory automatically
- Normalize filenames by replacing spaces with underscores
- Add date prefix to generated files
- Improve reliability with safer dimension detection
- Add script documentation and usage examples
This commit is contained in:
Lucas Vivohost committed 2026-09-14 12:43:38 +02:00
1 parent 3203817e51
commit aa48304220
3 files changed
+98 -41

No files matched your search

-17
View File
@@ -1,17 +0,0 @@
resize_var="x1080"
if [ "$1" != "" ]; then resize_var="$1"; fi
for file in *jpg ; do
if [ "$1" == "" ]; then
height="$(identify -quiet ${file} | cut -f3 -d' ' | cut -f2 -d'x')"
width="$(identify -quiet ${file} | cut -f3 -d' ' | cut -f1 -d'x')"
if [ "${height}" != "" ] && [ "${width}" != "" ]; then
if [ ${height} -gt ${width} ]; then
resize_var="x1080"
else
resize_var="1920"
fi
fi
fi
echo "Transform $file to ${resize_var}"
convert -quiet "$file" -resize ${resize_var} $(echo "NEW/${file}" | sed 's/jp[e]\?g/png/g')
done
-24
View File
@@ -1,24 +0,0 @@
resize_var="x1080"
DATE=$(date +"%d%m%y_")
if [ "$1" != "" ]; then resize_var="$1"; fi
for file in *jpg ; do
if [ "$1" == "" ]; then
height="$(identify -quiet ${file} | cut -f3 -d' ' | cut -f2 -d'x')"
width="$(identify -quiet ${file} | cut -f3 -d' ' | cut -f1 -d'x')"
if [ "${height}" != "" ] && [ "${width}" != "" ]; then
if [ ${height} -gt ${width} ]; then
resize_var="x1080"
else
resize_var="1920"
fi
fi
fi
file_new="$(echo ${file} | tr ' ' '_')"
if [[ "${file_new}" != "${file}" ]]; then
echo "Move $file to $file_new"
mv "$file" "$file_new"
fi
echo "Transform $file_new to ${resize_var}"
if [ ! -d NEW ]; then mkdir "NEW"; fi
convert -quiet "$file_new" -resize ${resize_var} $(echo "NEW/${DATE}${file_new}" | sed 's/jp[e]\?g/png/g')
done