Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
printf -- "\n\n-Unmounting the DMG file\n"
hdiutil detach /Volumes/DNGConverter_17_5

- name: Run reset.sh
- name: Test organizeGoProDNG.sh
run: |
chmod +x ./reset.sh
./reset.sh
chmod +x tests/test_organizeGoProDNG.sh
bash tests/test_organizeGoProDNG.sh

- name: Run organizeGoProDNG.sh
- name: Test compare_AdobeDNGConverter_arguments.sh
run: |
chmod +x ./organizeGoProDNG.sh
./organizeGoProDNG.sh
chmod +x tests/test_compare_AdobeDNGConverter_arguments.sh
bash tests/test_compare_AdobeDNGConverter_arguments.sh
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.autoSave": "onFocusChange",
"editor.rulers": [80, 120],
"files.trimTrailingWhitespace": true
}
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Adobe DNG Converter Scripts
A collection of scripts I made that utilize [Adobe Digital Negative (DNG) Converter](https://helpx.adobe.com/camera-raw/using/adobe-dng-converter.html)'s command line interface (CLI). Read my [blog post](https://mattpopovich.com/posts/how-to-use-adobe-dng-converter-from-the-command-line/) for additional details.
* [reset.sh](reset.sh)
* A script used while testing the other scripts in this repo. This script "resets" the folder to what it normally looks like coming fresh off of a GoPro.
* Should be ran before running [compare_AdobeDNGConverter_arguments.sh](compare_AdobeDNGConverter_arguments.sh) or [organizeGoProDNG.sh](organizeGoProDNG.sh)

* [compare_AdobeDNGConverter_arguments.sh](compare_AdobeDNGConverter_arguments.sh)
* Runs the *Adobe DNG Converter* from the CLI with a bunch of different arguments to compare their runtime and size of the converted files
* Expects [reset.sh](reset.sh) to be ran first to clean things up
* Runs the *Adobe DNG Converter* from the CLI with a bunch of different arguments to compare the arguments' runtime and size of the converted files
* [organizeGoProDNG.sh](organizeGoProDNG.sh)
* A script to convert a folder coming fresh off of a GoPro from
* `GOPR0000.GPR`
Expand Down
76 changes: 53 additions & 23 deletions compare_AdobeDNGConverter_arguments.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,80 @@
# This script runs Adobe DNG Converter CLI with a bunch of different arguments
# and compares their runtime and output file sizes

# WARNING: This script will be creating (and destroying) a .DNG folder

#
# This script is expecting to be ran in a folder that has a bunch of *.GPR files:
# $ ls
# GOPR0000.GPR
# GOPR0001.GPR
# compare_AdobeDNGConverter_arguments.sh
# $ ./compare_AdobeDNGConverter_arguments.sh

# $ bash compare_AdobeDNGConverter_arguments.sh
#
# Author: Matt Popovich (mattpopovich.com)

# Stop running script if any command fails
set -e

# Create a (hidden) .DNG folder to store our converted files
mkdir .DNG
# Constants
gpr_extension="GPR"
dng_dir=".DNG"
adobeDNGconverter="/Applications/Adobe DNG Converter.app/Contents/MacOS/Adobe DNG Converter"

# Will pass the argument given to Adobe DNG Converter
function test_flags(){
/Applications/Adobe\ DNG\ Converter.app/Contents/MacOS/Adobe\ DNG\ Converter $1 -d .DNG *.GPR
"$adobeDNGconverter" $1 -d "$dng_dir" *."$gpr_extension"
}

# Flag explanation: https://helpx.adobe.com/content/dam/help/en/camera-raw/digital-negative/jcr_content/root/content/flex/items/position/position-par/download_section/download-1/dng_converter_commandline.pdf
flags_array=(
"-c -p1 -cr7.1 -dng1.7.1" # Default values for AdobeDNGConverter 16.2.0 (lossless + compressed DNG files + medium JPEG preview)
"-u -p1 -cr7.1 -dng1.7.1" # Output uncompressed DNG files
"-l -p1 -cr7.1 -dng1.7.1" # Output linear DNG files
"-c -p1 -e -cr7.1 -dng1.7.1" # Embed original raw file inside DNG files
"-c -p0 -cr7.1 -dng1.7.1" # Set JPEG preview size to none
"-c -p2 -cr7.1 -dng1.7.1" # Set JPEG preview size to full size
"-c -p1 -fl -cr7.1 -dng1.7.1" # Embed fast load data inside DNG files
"-c -p1 -lossy -cr7.1 -dng1.7.1" # Use lossy compression
"-c -p1 -mp -cr7.1 -dng1.7.1" # Process multiple files in parallel
"-c -p1 -mp -lossy -cr7.1 -dng1.7.1" # Use lossy compression while processing in parallel
"-c -p1 -cr7.1 -dng1.7.1" # Default values for AdobeDNGConverter 16.2.0 (lossless + compressed DNG files + medium JPEG preview)
"-u -p1 -cr7.1 -dng1.7.1" # Output uncompressed DNG files
"-l -p1 -cr7.1 -dng1.7.1" # Output linear DNG files
"-c -p1 -e -cr7.1 -dng1.7.1" # Embed original raw file inside DNG files
"-c -p0 -cr7.1 -dng1.7.1" # Set JPEG preview size to none
"-c -p2 -cr7.1 -dng1.7.1" # Set JPEG preview size to full size
"-c -p1 -fl -cr7.1 -dng1.7.1" # Embed fast load data inside DNG files
"-c -p1 -lossy -cr7.1 -dng1.7.1" # Use lossy compression
"-c -p1 -mp -cr7.1 -dng1.7.1" # Process multiple files in parallel
"-c -p1 -mp -cr11.2 -dng1.7.1" # Upgrade minimum camera raw compatibility version
"-c -p1 -mp -cr12.4 -dng1.7.1" # ''
"-c -p1 -mp -cr13.2 -dng1.7.1" # ''
"-c -p1 -mp -cr14.0 -dng1.7.1" # ''
"-c -p1 -mp -cr15.3 -dng1.7.1" # ''
"-c -p1 -mp -lossy -cr7.1 -dng1.7.1" # Use lossy compression while processing in parallel
)

# Prevent this script from overwriting folders
if [ -d "$dng_dir" ]; then # Shell is not case sensitive
echo "ERROR: $dng_dir folder was found." \
"Please remove it (so that we don't mess it up) before running this script"
exit 1
fi

# Make sure we have the expected *.GPR files in this folder
if ! ls *."$gpr_extension" 1> /dev/null 2>&1; then
printf "%s\n" \
"ERROR: Did not find *.$gpr_extension files in this folder" \
"Are you running this script in the right folder?" \
"Extensions must be capitalized"
exit 2
fi

# Make sure the Adobe DNG Converter executable exists
if [ ! -x "$adobeDNGconverter" ]; then
echo "ERROR: Could not find executable: $adobeDNGconverter"
exit 3
fi

# Create a (hidden) .DNG folder to store our converted files
mkdir "$dng_dir"

# Get default statistics
start_time=$(ruby -e 'puts Time.now.to_f') # Alternatives: https://serverfault.com/a/423642/453183
test_flags "${flags_array[0]}" > /dev/null 2>/dev/null
end_time=$(ruby -e 'puts Time.now.to_f')
default_run_time=$(echo "${end_time} - ${start_time}" | bc)
default_file_sizes=$(ls -l .DNG | awk '{sum += $5} END {print sum}')
default_file_sizes=$(ls -l "$dng_dir" | awk '{sum += $5} END {print sum}')
echo "Default = ${default_file_sizes}B, ${default_run_time}s"
rm .DNG/*
rm "$dng_dir"/*

# Get statistics for flags
for flags in "${flags_array[@]}"; do
Expand All @@ -63,7 +93,7 @@ for flags in "${flags_array[@]}"; do
fi

# Calculate file size differences
file_size=$(ls -l .DNG | awk '{sum += $5} END {print sum}')
file_size=$(ls -l "$dng_dir" | awk '{sum += $5} END {print sum}')
size_difference=$(echo "${file_size} - ${default_file_sizes}" | bc)
percent_size_difference=$(echo "100 * ${size_difference} / ${default_file_sizes}" | bc)
if (( $(echo "$size_difference >= 0" | bc -l) )); then
Expand All @@ -73,8 +103,8 @@ for flags in "${flags_array[@]}"; do

# Output statistics
echo "Using flags ${flags} = ${time_difference}s (${percent_time_difference}%), ${size_difference}B (${percent_size_difference}%) vs default"
rm .DNG/*
rm "$dng_dir"/*
done

# Remove temporary folder
rm -r .DNG
rm -r "$dng_dir"
41 changes: 23 additions & 18 deletions organizeGoProDNG.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# A script to convert a folder coming fresh off of a GoPro from
# `GOPR0000.GPR`
# `GOPR0000.JPG`
# `GOPR0001.GPR`
# `GOPR0001.JPG`
# `organizeGoProDNG.sh`
# to
# `GPR/`
# `GOPR0000.GPR`
# `GOPR0001.GPR`
# `JPG/`
# `GOPR0000.JPG`
# `GOPR0001.JPG`
# `dng/`
# `GOPR0000.dng`
# `GOPR0001.dng`
# `organizeGoProDNG.sh`

# A script to convert a folder coming fresh off of a GoPro containing raw photos
# (with .GPR extensions) into a more organized folder structure, while also
# converting the .GPR files into .DNG files using Adobe DNG Converter.
# Ex.
# $ ls
# GOPR0000.GPR
# GOPR0000.JPG
# GOPR0001.GPR
# GOPR0001.JPG
# organizeGoProDNG.sh
# $ bash organizeGoProDNG.sh
# $ ls *
# GPR:
# GOPR0000.GPR GOPR0001.GPR

# JPG:
# GOPR0000.JPG GOPR0001.JPG
#
# dng:
# GOPR0000.dng GOPR0001.dng
#
# organizeGoProDNG.sh
#
# Author: Matt Popovich (mattpopovich.com)

# Stop running script if any command fails
Expand Down
27 changes: 0 additions & 27 deletions reset.sh

This file was deleted.

41 changes: 41 additions & 0 deletions tests/test_compare_AdobeDNGConverter_arguments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This script copies GoPro DNG files from the examples/ folder
# into the current folder, then runs compare_AdobeDNGConverter_arguments.sh
#
# This script should be run from the root of the repository Ex.
# $ bash tests/test_compare_AdobeDNGConverter_arguments.sh
#
# Author: Matt Popovich (mattpopovich.com)

# Stop running script if any command fails
set -e

# Copy the examples from the examples folder
cp examples/* tests/

# Confirm the expected files were copied
ls tests/GOPR0000.GPR
ls tests/GOPR0000.JPG
ls tests/GOPR0001.GPR
ls tests/GOPR0001.JPG

# Copy the organize script to be tested into the current folder
cp compare_AdobeDNGConverter_arguments.sh tests/

# Change to the tests folder
cd tests

# Run the compare script
./compare_AdobeDNGConverter_arguments.sh

# Clean up the copied files
rm GOPR0000.GPR
rm GOPR0000.JPG
rm GOPR0001.GPR
rm GOPR0001.JPG
rm compare_AdobeDNGConverter_arguments.sh

# Change back to the original folder
cd ..

# End of test
echo "organizeGoProDNG.sh test passed"
48 changes: 48 additions & 0 deletions tests/test_organizeGoProDNG.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This script copies GoPro DNG files from the examples/ folder
# into the current folder, then runs organizeGoProDNG.sh
#
# This script should be run from the root of the repository Ex.
# $ bash tests/test_organizeGoProDNG.sh
#
# Author: Matt Popovich (mattpopovich.com)

# Stop running script if any command fails
set -e

# Copy the examples from the examples folder
cp examples/* tests/

# Confirm the expected files were copied
ls tests/GOPR0000.GPR
ls tests/GOPR0000.JPG
ls tests/GOPR0001.GPR
ls tests/GOPR0001.JPG

# Copy the organize script to be tested into the current folder
cp organizeGoProDNG.sh tests/

# Change to the tests folder
cd tests

# Run the organize script
./organizeGoProDNG.sh

# Confirm the expected results
ls dng
ls JPG
ls GPR
ls dng/GOPR0000.DNG
ls JPG/GOPR0000.JPG
ls GPR/GOPR0000.GPR
ls dng/GOPR0001.DNG
ls JPG/GOPR0001.JPG
ls GPR/GOPR0001.GPR

# Change back to the original folder
cd ..

# Clean up the created files
rm -r tests/GPR tests/JPG tests/dng tests/organizeGoProDNG.sh

# End of test
echo "organizeGoProDNG.sh test passed"