Skip to content

Commit 0b1300e

Browse files
committed
feat(fov): auto-set lenses from EXIF when custom photo uploaded
Lens A is set to the detected focal length, Lens B to the next common step up (24→35→50→85→135→200) for a useful comparison.
1 parent 7e4cfa7 commit 0b1300e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/app/[locale]/fov-simulator/_components/FovSimulator.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import { extractFocalLength } from './extractFocalLength'
2222
import styles from './FovSimulator.module.css'
2323
import { useToolSession } from '@/lib/analytics/hooks/useToolSession'
2424

25+
const COMPARISON_STEPS = [24, 35, 50, 85, 135, 200] as const
26+
2527
export function FovSimulator() {
2628
const t = useTranslations('toolUI.fov-simulator')
2729
const { trackParam } = useToolSession()
@@ -44,6 +46,7 @@ export function FovSimulator() {
4446
setCustomImageSrc(URL.createObjectURL(file))
4547
dispatch({ type: 'SET_IMAGE', payload: -1 })
4648
const exif = await extractFocalLength(file)
49+
const detected = exif.focalLength35 ?? exif.focalLength
4750
if (exif.focalLength35) {
4851
setSourceFocalLength(exif.focalLength35)
4952
setExifDetected('fl35')
@@ -54,6 +57,11 @@ export function FovSimulator() {
5457
setSourceFocalLength(null)
5558
setExifDetected(null)
5659
}
60+
if (detected) {
61+
dispatch({ type: 'SET_LENS', payload: { index: 0, updates: { focalLength: detected } } })
62+
const comparison = COMPARISON_STEPS.find((f) => f > detected) ?? 135
63+
dispatch({ type: 'SET_LENS', payload: { index: 1, updates: { focalLength: comparison } } })
64+
}
5765
}, [customImageSrc])
5866

5967
const handleCustomRemove = useCallback(() => {

0 commit comments

Comments
 (0)