Created
June 6, 2026 14:30
-
-
Save sturmen/7e3b32a61b5b8a2fa541e1467e4d8600 to your computer and use it in GitHub Desktop.
Anamorphic Desqueeze DNG Script
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
| #!/bin/bash | |
| # Change to the directory where the script is located | |
| cd "$(dirname "$0")" | |
| # Clear the terminal screen | |
| clear | |
| # Tool Intro Text | |
| echo -e "\033[1mAnamorphic DNG EXIF DeSqueeze for Exiftool - written by Rupert Warries for MAC OS\033[0m\n\n\033[1m------------ \033[0m\n\nThis Tool will rewrite each DNG's EXIF data to allow Lightroom to render each image de-squeezed in DEVELOP module (library will still show squeezed image - any program that reads the pixel ratio in EXIF will also work)." | |
| echo -e "\n\nUSAGE INSTRUCTION :\n1. Place this script from inside the folder containing the DNG images for processing\n2. Drag tool into a terminal window to run and follow the prompts\n3. DNG filenames must contain no spaces - run the tool by dragging into a terminal window and following the prompts\n4. an installation of Exiftool must be present for this script to operate\n\n\033[1m------------ \033[0m" | |
| # Show the directory and ask for confirmation | |
| echo -e "\nAll DNG files present will be de-squeezed in the following directory:\n$(pwd)\n" | |
| read -p "Do you want to continue? (Y/N): " confirm | |
| # Check user input | |
| if [[ $confirm != [Yy] ]]; then | |
| echo "Processing cancelled." | |
| exit 1 | |
| fi | |
| # Ask for squeeze factor and loop until a valid positive number is entered. | |
| # Values greater than 1.0 stretch horizontally. Values less than 1.0 stretch vertically. | |
| while true; do | |
| read -p "Enter the lens squeeze factor (e.g. 0.75, 1.0, 1.33, 1.5, 2.0): " squeeze_factor | |
| # Check if the input is a valid positive number, including values like .75 | |
| if [[ $squeeze_factor =~ ^([0-9]+([.][0-9]*)?|[.][0-9]+)$ ]] && awk "BEGIN { exit !($squeeze_factor > 0) }"; then | |
| break | |
| else | |
| echo "Desqueeze must be a positive number" | |
| fi | |
| done | |
| # DefaultScale is stored as two values: horizontal scale first, vertical scale second. | |
| # Keep the unstretched dimension at 1.0. For values below 1.0, invert the input so | |
| # the image is stretched vertically instead of squeezed horizontally. | |
| if awk "BEGIN { exit !($squeeze_factor >= 1) }"; then | |
| default_scale_h=$(awk -v v="$squeeze_factor" 'BEGIN { printf "%.2f", v }') | |
| default_scale_v="1.0" | |
| else | |
| default_scale_h="1.0" | |
| default_scale_v=$(awk -v v="$squeeze_factor" 'BEGIN { printf "%.2f", 1 / v }') | |
| fi | |
| # Process files in the current directory | |
| while IFS= read -r -d '' file; do | |
| exiftool -DefaultScale="$default_scale_h $default_scale_v" -overwrite_original "$file" | |
| done < <(find . -maxdepth 1 -type f \( -iname "*.DNG" -o -iname "*.dng" \) -print0) | |
| # Print confirmation message | |
| echo -e " | |
| [1mProcessing complete[0m | |
| DNG's EXIF rewritten with a $default_scale_h $default_scale_v DefaultScale from a $squeeze_factor squeeze factor | |
| " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment