Displaying Apple HEIF Photos on the Web
A quick guide to converting iPhone HEIF photos for web display
This tutorial requires using the Mac terminal.
Format Conversion
Recommended Presets
Standard Web Display (Recommended)
# Width 1920px, quality 80%, suitable for most websites
for file in *.HEIC *.heic; do
if [ -f "$file" ]; then
sips -s format jpeg -s formatOptions 80 --resampleWidth 1920 "$file" --out "${file%.*}.jpg"
echo "Converted: ${file%.*}.jpg"
fi
done
- File size: Typically 200KB-800KB
- Use case: Blogs, portfolios, photo galleries
- Load speed: Good
High Compression (Fast Loading)
# Width 1280px, quality 75%, smaller files
for file in *.HEIC *.heic; do
if [ -f "$file" ]; then
sips -s format jpeg -s formatOptions 75 --resampleWidth 1280 "$file" --out "${file%.*}.jpg"
echo "Converted: ${file%.*}.jpg"
fi
done
- File size: Typically 100KB-400KB
- Use case: Mobile-first sites, slow network regions
High Quality (Visual Priority)
# Width 2560px, quality 85%, better visual quality
for file in *.HEIC *.heic; do
if [ -f "$file" ]; then
sips -s format jpeg -s formatOptions 85 --resampleWidth 2560 "$file" --out "${file%.*}.jpg"
echo "Converted: ${file%.*}.jpg"
fi
done
- File size: Typically 500KB-1.5MB
- Use case: Photography showcases, premium sites
One-Liner Versions (Quick Use)
# Standard preset
for file in *.HEIC *.heic; do sips -s format jpeg -s formatOptions 80 --resampleWidth 1920 "$file" --out "${file%.*}.jpg" && echo "Done: ${file%.*}.jpg"; done
# High compression preset
for file in *.HEIC *.heic; do sips -s format jpeg -s formatOptions 75 --resampleWidth 1280 "$file" --out "${file%.*}.jpg" && echo "Done: ${file%.*}.jpg"; done
Batch Renaming
Basic Renaming
# Append identifier to filename (no separator)
for file in *.jpg; do
mv "$file" "${file%.*}LocationName.jpg"
echo "Renamed: $file -> ${file%.*}LocationName.jpg"
done
# Append identifier to filename (with underscore separator)
for file in *.jpg; do
mv "$file" "${file%.*}_LocationName.jpg"
echo "Renamed: $file -> ${file%.*}_LocationName.jpg"
done
One-Liner Versions
# No separator
for file in *.jpg; do mv "$file" "${file%.*}LocationName.jpg" && echo "Done: ${file%.*}LocationName.jpg"; done
# With underscore separator
for file in *.jpg; do mv "$file" "${file%.*}_LocationName.jpg" && echo "Done: ${file%.*}_LocationName.jpg"; done
Safe Preview Version
# Preview the rename operations first
for file in *.jpg; do echo "Will rename: $file -> ${file%.*}_LocationName.jpg"; done
# Execute after confirming
for file in *.jpg; do mv "$file" "${file%.*}_LocationName.jpg"; done
Complete Workflow
# Step 1: Convert format
for file in *.HEIC *.heic; do sips -s format jpeg -s formatOptions 80 --resampleWidth 1920 "$file" --out "${file%.*}.jpg" && echo "Done: ${file%.*}.jpg"; done
# Step 2: Rename
for file in *.jpg; do mv "$file" "${file%.*}_JiuzhaiValley.jpg" && echo "Done: ${file%.*}_JiuzhaiValley.jpg"; done