File size: 2,252 Bytes
ccfbb46 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Change directory to the workspace root where the script is located
cd "$(dirname "$0")"
echo "=== 1. Cleaning existing intermediate files ==="
rm -f report_architectural_inference.aux \
report_architectural_inference.log \
report_architectural_inference.tex \
report_architectural_inference.toc \
report_architectural_inference.pdf \
report_architectural_inference.html
rm -rf report_architectural_inference_files
echo "=== 2. Converting new/updated PNG images to JPEGs ==="
uv run python -c "
import os
from PIL import Image
output_dir = 'resources/task_vin'
if os.path.exists(output_dir):
for root, dirs, files in os.walk(output_dir):
for f in files:
if f.endswith('.png'):
png_path = os.path.join(root, f)
jpg_path = png_path[:-4] + '.jpg'
# Convert if JPG doesn't exist or is older than PNG (meaning PNG was updated)
if not os.path.exists(jpg_path) or os.path.getmtime(png_path) > os.path.getmtime(jpg_path):
try:
img = Image.open(png_path)
img_rgb = img.convert('RGB')
img_rgb.save(jpg_path, 'JPEG', quality=85)
print(f'Converted: {png_path} -> {jpg_path}')
except Exception as e:
print(f'Error converting {png_path}: {e}')
"
echo "=== 3. Rendering Quarto report to PDF ==="
quarto render report_architectural_inference.qmd --to pdf
echo "=== 4. Cleaning up compilation artifacts ==="
rm -f report_architectural_inference.aux \
report_architectural_inference.log \
report_architectural_inference.tex \
report_architectural_inference.toc \
report_architectural_inference.html
rm -rf report_architectural_inference_files
# Delete converted JPEGs from resources to prevent duplication
if [ -d "resources/task_vin" ]; then
echo "=== Removing temporary converted JPEG files ==="
find resources/task_vin -name "*.jpg" -type f -delete
fi
echo "=== Build Complete! report_architectural_inference.pdf has been generated successfully. ==="
|