From e9481e7593e6883cad08a92aa5448e948a19434a Mon Sep 17 00:00:00 2001 From: Rajendra Reddy Date: Wed, 4 Mar 2026 09:56:58 +0000 Subject: [PATCH] Add .gitea/workflows/compressimages.yml --- .gitea/workflows/compressimages.yml | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .gitea/workflows/compressimages.yml diff --git a/.gitea/workflows/compressimages.yml b/.gitea/workflows/compressimages.yml new file mode 100644 index 0000000..f5e9545 --- /dev/null +++ b/.gitea/workflows/compressimages.yml @@ -0,0 +1,52 @@ +name: Enforce Image Standards + +on: + pull_request: + paths: + - '**.jpg' + - '**.jpeg' + - '**.png' + workflow_dispatch: + +jobs: + optimize: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Install Image Tools + run: | + sudo apt-get update + sudo apt-get install -y imagemagick jpegoptim pngquant + + # Resize images larger than 1920px (keeps aspect ratio) + - name: Resize Oversized Images + run: | + find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" \) \ + -exec mogrify -resize 1920x1920\> {} \; + + # Optimize JPEG safely + - name: Optimize JPEG + run: | + find . -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) \ + -exec jpegoptim --strip-all --max=85 {} \; + + # Optimize PNG safely + - name: Optimize PNG + run: | + find . -type f -iname "*.png" \ + -exec pngquant --force --ext .png --quality=75-90 {} \; + + # Commit only if changes exist + - name: Commit Optimized Images + run: | + git config --global user.name "gitea-actions" + git config --global user.email "actions@local" + + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "Auto resize and optimize images" + git push origin HEAD:${{ github.head_ref }} + fi