sunny16 calculator
To upload files, please first save the app
import streamlit as st
st.title("Sunny 16 Rule Calculator")
st.write("""
The Sunny 16 Rule is a method to estimate correct exposure for photography without using a light meter.
The basic rule states: On a sunny day, set aperture to f/16 and shutter speed to the reciprocal of the ISO speed.
""")
# Input for ISO
iso = st.selectbox("Select ISO", [100, 200, 400, 800, 1600, 3200, 6400])
# Input for lighting conditions
lighting_conditions = st.selectbox(
"Select Lighting Conditions",
[
"Sunny (f/16)",
"Slightly Overcast (f/11)",
"Overcast (f/8)",
"Heavy Overcast (f/5.6)",
"Sunset (f/4)",
"Deep Shade/Dusk (f/2.8)"
]
)
# Get the f-number from the selected lighting condition
f_number = float(lighting_conditions.split("(f/")[1].strip(")"))
# Calculate the base shutter speed (reciprocal of ISO)
base_shutter = 1/iso
st.subheader("Calculated Exposure Settings:")
st.write(f"📷 Aperture: f/{f_number}")
st.write(f"âš¡ Base Shutter Speed: 1/{int(1/base_shutter)} second")
# Show equivalent exposures
st.subheader("Equivalent Exposures:")
st.write("Here are some equivalent exposures that will give you the same exposure value:")
exposures = []
current_f = f_number
current_shutter = base_shutter
# Generate 3 wider apertures and 3 narrower apertures
for i in range(-3, 4):
new_f = current_f * (2 ** (i/2))
new_shutter = current_shutter * (2 ** i)
if new_f >= 1.4 and new_shutter <= 1: # Only show realistic values
exposures.append({
"Aperture": f"f/{new_f:.1f}",
"Shutter Speed": f"1/{int(1/new_shutter) if new_shutter < 1 else new_shutter} sec"
})
st.table(exposures)
st.info("""
Remember:
- Opening up the aperture by one stop (smaller f-number) requires doubling the shutter speed
- Closing down the aperture by one stop (larger f-number) requires halving the shutter speed
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?