# Load the exported picture list from cPicture bilder.xml [xml]$pictureXML = New-Object xml $pictureXML.Load("$PSScriptRoot\blog\bilder.xml") $picturesEVxml = @() # Get the picture exposure data from the xml file. $pictureXML.List.Picture | ForEach-Object { # File="DSC_4121.JPG" Aperture="f/4,0" Shutterspeed="1/250s" Iso="ISO 320/26°" if ($_.Aperture -match "f/(\d(?:,\d+)?)") { $Aperture = [double]($matches[1].Replace(",", ".")) if ($_.Shutterspeed -match "1/(\d+)s") { $Shutterspeed = [double]($matches[1]) if ($_.Iso -match "ISO (\d+)(?:/d+°)?") { $Iso = [double]($matches[1]) $picturesEVxml += ,@($($_.File), $Shutterspeed, $Aperture, $Iso) } } } } # Set up the list of pictures with the exposure settings. $picturesEVlist = @( # Name, Speed, Aperture, ISO @("DSC_4121.NEF", 250, 4.0, 320), @("DSC_4122.NEF", 250, 5.0, 200), @("DSC_4123.NEF", 250, 5.6, 110), @("DSC_4124.NEF", 250, 4.0, 360), @("DSC_4125.NEF", 250, 5.0, 200), @("DSC_4126.NEF", 250, 5.6, 180), @("DSC_4127.NEF", 250, 5.6, 160), @("DSC_4128.NEF", 250, 4.0, 250), @("DSC_4129.NEF", 250, 5.0, 200), @("DSC_4130.NEF", 250, 5.6, 140), @("DSC_4131.NEF", 250, 5.6, 125) ) #$picturesEV = $picturesEVlist $picturesEV = $picturesEVxml # Set the reference picture to which all other pictures will be aligned to. $refPictureName = "DSC_4131.JPG" # Get the data for the reference picture. foreach ($pictureEV in $picturesEV) { if ($refPictureName -eq $pictureEV[0]) { $refPictureEV = $pictureEV break } } function log2([double]$x) { [Math]::Log($x) / [Math]::Log(2.0) } function Get-ExposureText($EV) { "1/$($EV[1])s f/$($EV[2]) ISO$($EV[3])" } [string]$expRef = Get-ExposureText $refPictureEV "Adjust exposure to match $refPictureName [$expRef]:" # Calulate the exposure correction for each picture. foreach ($pictureEV in $picturesEV) { [string]$name = $pictureEV[0] # Example a to b: # 1/(250) to 1/(500) = -1EV , (log2 250) - (log2 500) # f5.6 to f4 = +1EV , 2*((log2 5.6) - (log2 4)) # ISO200 to ISO100 = -1EV , (log2 100) - (log2 200) # Calulate correction values from speed, f-stop and iso. [double]$speedEV = (log2 $pictureEV[1]) - (log2 $refPictureEV[1]) [double]$fEV = 2 * ((log2 $pictureEV[2]) - (log2 $refPictureEV[2])) [double]$isoEV = (log2 $refPictureEV[3]) - (log2 $pictureEV[3]) [double]$EV = [math]::Round($speedEV + $fEV + $isoEV, 2) [string]$sign = if ($eV -gt 0.0) { "+" } else { "" } [string]$exp = Get-ExposureText $pictureEV # Output result. "$name [$exp] = $sign{0:g2}EV" -f $EV }