jedmund-svelte/scripts/check-photo-colors.ts
Justin Edmund cfde42c336 feat(colors): improve color analysis with better algorithms and scripts
- Add comprehensive color analysis scripts for batch processing
- Improve color extraction algorithms in color-utils.ts
- Add endpoints for reanalyzing colors on existing photos
- Add cloudinary color extraction endpoint
- Create detailed README for color analysis scripts
- Support both single and batch color reanalysis
- Improve color palette generation accuracy

Enhances photo color analysis for better visual presentation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 01:13:12 +01:00

66 lines
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()