jedmund-svelte/scripts/check-photo-colors.ts
Justin Edmund a8978373e0 chore: add color analysis scripts
- analyze-image-colors.ts: Test color extraction on local images
- check-photo-colors.ts: Verify color data in database
- find-image-colors.ts: Extract colors from Cloudinary URLs
- reanalyze-colors.ts: Bulk reprocess colors for all media

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-19 01:59:36 +01:00

63 lines
No EOL
1.5 KiB
TypeScript

#!/usr/bin/env tsx
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function checkPhotoColors() {
try {
// Count total photography media
const totalPhotos = await prisma.media.count({
where: { isPhotography: true }
})
// Count photos with dominant color
const photosWithColor = await prisma.media.count({
where: {
isPhotography: true,
dominantColor: { not: null }
}
})
// Count photos without dominant color
const photosWithoutColor = await prisma.media.count({
where: {
isPhotography: true,
dominantColor: null
}
})
// Get some examples
const examples = await prisma.media.findMany({
where: {
isPhotography: true,
dominantColor: { not: null }
},
select: {
filename: true,
dominantColor: true,
thumbnailUrl: true
},
take: 5
})
console.log('=== Photography Color Analysis ===')
console.log(`Total photography items: ${totalPhotos}`)
console.log(`With dominant color: ${photosWithColor} (${((photosWithColor/totalPhotos)*100).toFixed(1)}%)`)
console.log(`Without dominant color: ${photosWithoutColor} (${((photosWithoutColor/totalPhotos)*100).toFixed(1)}%)`)
if (examples.length > 0) {
console.log('\n=== Examples with dominant colors ===')
examples.forEach(media => {
console.log(`${media.filename}: ${media.dominantColor}`)
})
}
} catch (error) {
console.error('Error:', error)
} finally {
await prisma.$disconnect()
}
}
checkPhotoColors()