From 0ee0e120ca397af908bc0aecd6a5fd096fcc324c Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 5 Apr 2025 17:02:58 -0500 Subject: [PATCH] Separate final ts-exif-parser references --- src/photo/index.ts | 2 +- src/utility/exif-format.ts | 27 +++++++++++++++++++++++++++ src/utility/exif.ts | 27 --------------------------- 3 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 src/utility/exif-format.ts diff --git a/src/photo/index.ts b/src/photo/index.ts index 3e25eb9d..64dceac8 100644 --- a/src/photo/index.ts +++ b/src/photo/index.ts @@ -16,7 +16,7 @@ import { formatIso, formatExposureCompensation, formatExposureTime, -} from '@/utility/exif'; +} from '@/utility/exif-format'; import { parameterize } from '@/utility/string'; import camelcaseKeys from 'camelcase-keys'; import { isBefore } from 'date-fns'; diff --git a/src/utility/exif-format.ts b/src/utility/exif-format.ts new file mode 100644 index 00000000..bdbaeddb --- /dev/null +++ b/src/utility/exif-format.ts @@ -0,0 +1,27 @@ +import { formatNumberToFraction, roundToString } from './number'; + +export const formatAperture = (aperture?: number) => + aperture + ? `ƒ/${roundToString(aperture)}` + : undefined; + +export const formatIso = (iso?: number) => + iso ? `ISO ${iso}` : undefined; + +export const formatExposureTime = (exposureTime = 0) => + exposureTime > 0 + ? exposureTime < 1 + ? `1/${Math.floor(1 / exposureTime)}s` + : `${exposureTime}s` + : undefined; + +export const formatExposureCompensation = (exposureCompensation?: number) => { + if ( + exposureCompensation && + Math.abs(exposureCompensation) > 0.01 + ) { + return `${formatNumberToFraction(exposureCompensation)}ev`; + } else { + return undefined; + } +}; diff --git a/src/utility/exif.ts b/src/utility/exif.ts index 9eb7c65e..c0fb077a 100644 --- a/src/utility/exif.ts +++ b/src/utility/exif.ts @@ -1,5 +1,4 @@ import { OrientationTypes, type ExifData } from 'ts-exif-parser'; -import { formatNumberToFraction, roundToString } from './number'; const OFFSET_REGEX = /[+-]\d\d:\d\d/; @@ -61,32 +60,6 @@ export const convertApertureValueToFNumber = ( } }; -export const formatAperture = (aperture?: number) => - aperture - ? `ƒ/${roundToString(aperture)}` - : undefined; - -export const formatIso = (iso?: number) => - iso ? `ISO ${iso}` : undefined; - -export const formatExposureTime = (exposureTime = 0) => - exposureTime > 0 - ? exposureTime < 1 - ? `1/${Math.floor(1 / exposureTime)}s` - : `${exposureTime}s` - : undefined; - -export const formatExposureCompensation = (exposureCompensation?: number) => { - if ( - exposureCompensation && - Math.abs(exposureCompensation) > 0.01 - ) { - return `${formatNumberToFraction(exposureCompensation)}ev`; - } else { - return undefined; - } -}; - const SOS = 0xffda; const APP1 = 0xffe1; const EXIF = 0x45786966;