diff --git a/03-Game-Installer.sh b/03-Game-Installer.sh index 7437c1a..2b926e8 100755 --- a/03-Game-Installer.sh +++ b/03-Game-Installer.sh @@ -502,15 +502,30 @@ if compgen -G "${input_dir}/*" > /dev/null; then base_name=$(basename "${file%.*}") # Define output filename with .png extension - output="${ARTWORK_DIR}/${base_name}.png" - - # Convert each file to .png with resizing and 8-bit depth - convert "$file" -resize 256x256! -depth 8 -alpha off "$output" | tee -a "${LOG_FILE}" + output="${ARTWORK_DIR}/tmp/${base_name}.png" + + # Get image dimensions using identify + dimensions=$(identify -format "%w %h" "$file") + width=$(echo "$dimensions" | cut -d' ' -f1) + height=$(echo "$dimensions" | cut -d' ' -f2) + + # Check if width >= 256 and height >= width + if [[ $width -ge 256 && $height -ge $width ]]; then + # Convert each file to .png with resizing and 8-bit depth + echo "Converting $file" + convert "$file" -resize 256x256^ -gravity center -extent 256x256 -depth 8 -alpha off "$output" | tee -a "${LOG_FILE}" + rm "$file" + else + echo "Skipping $file: does not meet size requirements" | tee -a "${LOG_FILE}" + rm "$file" + fi done else - echo "No files to process in ${input_dir}" | tee -a "${LOG_FILE}" + echo "No files to process in ${input_dir}" | tee -a "${LOG_FILE}" fi +cp ${ARTWORK_DIR}/tmp/* ${ARTWORK_DIR} + echo | tee -a "${LOG_FILE}" echo "Creating game assets..." | tee -a "${LOG_FILE}" diff --git a/helper/art_downloader.js b/helper/art_downloader.js index 5cb36e5..a93599e 100644 --- a/helper/art_downloader.js +++ b/helper/art_downloader.js @@ -87,7 +87,7 @@ const puppeteer = require('puppeteer'); // Import Puppeteer after ensuring it's const img = document.querySelector('img[src^="https://media.ign.com"]'); if (img) { - return img.src; + return img.src.split('?')[0]; // Remove query parameters } return null; }); @@ -101,7 +101,7 @@ const puppeteer = require('puppeteer'); // Import Puppeteer after ensuring it's const img = document.querySelector('img[src^="https://ps2media.ign.com"]'); if (img) { - return img.src; + return img.src.split('?')[0]; // Remove query parameters } return null; }); @@ -115,7 +115,7 @@ const puppeteer = require('puppeteer'); // Import Puppeteer after ensuring it's const img = document.querySelector('img[src^="https://ps3media.ign.com"]'); if (img) { - return img.src; + return img.src.split('?')[0]; // Remove query parameters } return null; }); @@ -143,7 +143,7 @@ const puppeteer = require('puppeteer'); // Import Puppeteer after ensuring it's const img = document.querySelector('img[src^="https://assets1.ignimgs.com"]'); if (img) { - return img.src; + return img.src.split('?')[0]; // Remove query parameters } return null; });