deckhearth/scripts/fix-lorcana-images.js
Randall Stillwell afb79c57d9 Major Scanner Improvements
🔧 Gemini AI Integration:
- Added Google Gemini API as default OCR service
- Auto-configures from GEMINI_AI_API_KEY environment variable
- Fixed Puter.js authentication issues
- Enhanced OCR settings with connection testing

🎨 Redesigned Scanner Queue:
- New thumbnail + content layout with checkbox overlay
- Smart quantity management (duplicates increment quantity)
- Complete card information display from database
- Two-row action layout (primary/secondary actions)
- Floating bottom toolbar for bulk actions
- Real card images from database

�� Enhanced User Experience:
- Fixed Canvas2D performance warnings
- Better error handling and fallbacks
- Improved responsive design
- Database confirmation indicators
- Professional card scanning workflow

📱 Mobile Ready:
- Optimized layouts for mobile scanning
- Touch-friendly controls and interactions
- Improved visual feedback and status indicators
2025-07-29 14:19:48 -05:00

88 lines
No EOL
3 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import dotenv from 'dotenv';
import { neon } from '@neondatabase/serverless';
dotenv.config({ path: '.env.local' });
async function fixLorcanaImages() {
const sql = neon(process.env.POSTGRES_URL);
try {
console.log('🏰 Fixing Lorcana card images...');
// Get all Lorcana cards with image URLs
const lorcanaCards = await sql`
SELECT id, name, image_url, stock_image_url
FROM cards
WHERE game = 'Lorcana' AND image_url IS NOT NULL
`;
console.log(`📸 Found ${lorcanaCards.length} Lorcana cards to process`);
let updatedCount = 0;
for (const card of lorcanaCards) {
let needsUpdate = false;
let newImageUrl = card.image_url;
let newStockImageUrl = card.stock_image_url;
// Check if we're using a small image as the main image
if (card.image_url && card.image_url.includes('-716.webp')) {
// Replace with 1024px version for main image
newImageUrl = card.image_url.replace('-716.webp', '-1024.webp');
newStockImageUrl = card.image_url; // Keep 716px as thumbnail
needsUpdate = true;
} else if (card.image_url && card.image_url.includes('-512.webp')) {
// Replace with 1024px version for main image
newImageUrl = card.image_url.replace('-512.webp', '-1024.webp');
newStockImageUrl = card.image_url; // Keep 512px as thumbnail
needsUpdate = true;
}
// Also check if both image_url and stock_image_url are the same small image
if (card.image_url === card.stock_image_url && card.image_url &&
(card.image_url.includes('-716.webp') || card.image_url.includes('-512.webp'))) {
// They're the same small image, fix this
if (card.image_url.includes('-716.webp')) {
newImageUrl = card.image_url.replace('-716.webp', '-1024.webp');
newStockImageUrl = card.image_url; // Keep original as thumbnail
} else if (card.image_url.includes('-512.webp')) {
newImageUrl = card.image_url.replace('-512.webp', '-1024.webp');
newStockImageUrl = card.image_url; // Keep original as thumbnail
}
needsUpdate = true;
}
if (needsUpdate) {
await sql`
UPDATE cards
SET image_url = ${newImageUrl},
stock_image_url = ${newStockImageUrl},
updated_at = CURRENT_TIMESTAMP
WHERE id = ${card.id}
`;
console.log(`✅ Updated ${card.name}: ${card.image_url}${newImageUrl}`);
updatedCount++;
}
}
console.log(`🎉 Updated ${updatedCount} Lorcana cards with higher quality images`);
if (updatedCount === 0) {
console.log(' No cards needed updating - they may already have high quality images');
}
} catch (error) {
console.error('❌ Error fixing Lorcana images:', error);
}
}
// Run the script
fixLorcanaImages()
.then(() => {
console.log('✅ Script completed');
process.exit(0);
})
.catch((error) => {
console.error('❌ Script failed:', error);
process.exit(1);
});