Created
January 21, 2021 11:44
-
-
Save JasonThomasData/2467fbf2f49f5af391e396fd5b201fbf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
############################################ | |
## This program converts a directory of .NEF images to jpeg, png or TIFF format. | |
## It also resizes the images | |
## | |
## Examples: | |
## ./FILENAME FORMAT WIDTH_RESIZE | |
## ./batchConvertNEF.sh png 500 | |
## ./batchConvertNEF.sh jpeg | |
outputExtensionOptions=(jpeg tiff png) #Check the convert -h docs for available save options, if not an option, resorts to dcraw type | |
outputFileExtension=$1 | |
if [[ -z "$outputFileExtension" ]]; then | |
echo "need output param, eg: $0 <jpeg|png|tiff>" | |
exit 1 | |
fi | |
if [[ ! ${outputExtensionOptions[*]} =~ $outputFileExtension ]]; then | |
echo "valid outputs are: ${outputExtensionOptions[*]}" | |
exit 1 | |
fi | |
echo "Saving NEF files as $outputFileExtension" | |
outputImageWidth=$2 | |
if [[ -n "$outputImageWidth" ]]; then | |
echo "Images will be made $outputImageWidth px wide" | |
else | |
echo "To resize image, do: $0 <jpeg|png|tiff> <output width in px>" | |
fi | |
for fileName in $(ls) | |
do | |
if [[ $fileName != *".NEF" ]]; then | |
continue | |
fi | |
echo $fileName | |
if [[ -z "$outputImageWidth" ]]; then | |
dcraw -c $fileName | convert - "$fileName.$outputFileExtension" | |
else | |
dcraw -c $fileName | convert - -scale $outputImageWidth "$fileName.$outputFileExtension" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For my future reference, this is what my Nikon camera produces... NEF format