
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
exposure-utility
Advanced tools
This code is a quick TypeScript port of some JavaScript code I had written for this Android application.
There's nothing particularly scientific or pretty about this module. It uses predetermined tables and uses offsets to determine exposure settings that will be familiar to most photographers and camera models as opposed to generated, but potentially unfamiliar or unsupported values.
The implementation is simple and it won't error out in some areas that it arguably should, e.g you pass a â…“ stop value to an instance of ExposureCalculator that is using full stops.
Enjoy! Feel free to contribute by opening a PR or Issue. Happy snapping 📷 👍
const Exposure = require('exposure-utility')
import * as Exposure from 'exposure-utility'
// Create an exposure calculator that uses half stop incerments
const calculator = new Exposure.ExposureCalculator(
Exposure.ExposureIncrements.Halves
)
const shutter = calculator.calculateNewShutterFromBaseExposure(
// Our base exposure
{
iso: '1600',
aperture: 'f/2.8',
shutter: '1/4'
},
// The parts of our final exposure, minus the shutter since we
// want that calculated for us
{
aperture: 'f/19',
iso: '200'
}
)
if (typeof shutter === 'string') {
// This shutter speed result can be dialed in, e.g 30"
} else {
// We received a shutter speed as a number of seconds, e.g 91 in this example
// We need to use bulb mode on most cameras and manually time 91 seconds
}
Create an exposure calculator instance. The given instance will operate using the given increments similar to a camera set to use full, half, or third stops.
const Exposure = require('exposure-utility')
const calculator = new Exposure.ExposureCalculator(
Exposure.ExposureIncrements.Thirds
)
Returns all shutter speeds the given calculator supports. Support is determined
by the increments argument passed to the constructor for ExposureCalculator.
Similar to calculator.getShutterSpeeds() but returns apertures.
Similar to calculator.getShutterSpeeds() but returns ISO values.
Given a base exposure and a partial final exposure calculate the necessary
shutter speed component for the final exposure.
const base = {
// Our base or test exposure we used to determine composition and exposure
iso: '1600',
aperture: 'f/2.8',
shutter: '1/4'
}
const final = {
// Our final exposure settings, minus the shutter since we need that
// calculated for us to get an equivalent amount of light with our new ISO
// and aperture value
aperture: 'f/19',
iso: '200'
}
// Result will be a number if the resulting shutter speed is greater than 30
// seconds, or a string from ExposureCalculator.getShutterSpeeds() if between
// 1/8000 or 30 seconds
const shutter = calculator.calculateNewShutterFromBaseExposure(
base, final
)
Similar to calculateNewShutterFromBaseExposure but instead calculates the
required aperture.
Similar to calculateNewShutterFromBaseExposure but instead calculates the
required ISO.
Determines the stops separating a base value and final value. For example, the number of stops between two shutter speeds:
const increments = calculator.getIncrements()
const baseShutter = '1/200'
const finalShutter = '1/4'
const validShutters = calculator.getShutterSpeeds()
const stops = calculator.getDifferenceInStops(
validShutters,
baseShutter,
finalShutter
)
console.log(`
There is a difference of ${stops} ${increments} stops between
${baseShutter} and ${finalShutter}
`)
// Prints "There is a difference of 17 â…“ stops between 1/200 and 1/4"
Similar to getShutterSpeeds but for aperture values.
Similar to getShutterSpeeds but for ISO values.
A constant that contains all various shutter speeds for all stop/increments. It has the following format:
{
'â…“': [
'30"',
'25"',
'20"',
'15"',
'13"',
// etc...
'1/8000'
]
'½': [
'30"',
'20"',
'15"',
'10"',
'8"',
// etc...
'1/8000'
]
'Full': [
'30"',
'15"',
'8"',
'4"',
'2"',
// etc...
'1/8000'
]
}
Identical structure to shutterValues, but instead contains apertures.
Identical structure to shutterValues, but instead contains ISOs.
FAQs
Photographic exposure calculation utilities
We found that exposure-utility demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.