npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

exposure-utility

v0.3.0

Published

Photographic exposure calculation utilities

Downloads

13

Readme

exposure-utility

https://travis-ci.org/evanshortiss/exposure-utility npm version https://coveralls.io/repos/github/evanshortiss/exposure-utility TypeScript

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 📷 👍

Usage

Supported Node.js & TypeScript Versions

  • TypeScipt 2.9+
  • Node.js 6+

Node.js & ES5

const Exposure = require('exposure-utility')

TypeScript & ES6

import * as Exposure from 'exposure-utility'

Example

// 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
}

API

new ExposureCalculator(increments)

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
)

ExposureCalculator.getShutterSpeeds()

Returns all shutter speeds the given calculator supports. Support is determined by the increments argument passed to the constructor for ExposureCalculator.

ExposureCalculator.getApertures()

Similar to calculator.getShutterSpeeds() but returns apertures.

ExposureCalculator.getIsos()

Similar to calculator.getShutterSpeeds() but returns ISO values.

ExposureCalculator.calculateNewShutterFromBaseExposure(base, final)

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
)

ExposureCalculator.calculateNewApertureFromBaseExposure(base, final)

Similar to calculateNewShutterFromBaseExposure but instead calculates the required aperture.

ExposureCalculator.calculateNewIsoFromBaseExposure(base, final)

Similar to calculateNewShutterFromBaseExposure but instead calculates the required ISO.

ExposureCalculator.getDifferenceInStops(values, base, final)

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"

getApertures(increments)

Similar to getShutterSpeeds but for aperture values.

getIsos(increments)

Similar to getShutterSpeeds but for ISO values.

shutterValues

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'
  ]
}

apertureValues

Identical structure to shutterValues, but instead contains apertures.

isoValues

Identical structure to shutterValues, but instead contains ISOs.