Charlie Meyer's Blog

A one line code change inside iOS made me waste 5 minutes

Warning: This post isn’t important.

I am the sole maintainer of my dad’s art website. The codebase has slowly grown more sane over the years, but I’m not using a CMS to manage the content of the site [1]. Updating the site is a manual process held together with a shell script. Once every few months, I’ll head out to my dad’s studio, take some photos of new work with my iPhone, and head inside to run my scripts to update the running site.



picture of paintings in an art studio There are a lot of paintings in the studio


Here are the contents of the README.md file in the site’s git repo (The README itself was a huge innovation introduced in 2021) [2]

# update site
(assumes imagemagick is installed)

1. download heic from phone
1. make folder for the days photos in scripts
1. download a csv with just today's info, including the table header. 
put in a file called info.csv in scripts/FOLDER_NAME
1. run sh update.sh [FOLDER NAME] [NEW NUMBER] (ex. update.sh 313_22 385)
  NO LEADING ZEROS! LOL that makes bash think it's an octal number
  MAKE SURE YOU SAY y when it says confirm! >:)
1. npm run start
1. mess with the order in artinfo.json
1. add colors... ? this should move into the csv step. (update 10/2/2022: yeah).
1. throw today's files into the old_imports folder (so it's git ignoreed)
1. commit and push

Let’s look at update.sh:

cd $1
num=$2; for i in *.heic; do mv "$i" "$(printf '%05d' $num).${i#*.}"; ((num++)); done
mkdir jpgs imgs thumbs
ls *.heic | sed -e 's/\.heic$//' | xargs -I {} magick convert {}.heic ./jpgs/{}.jpg
cd jpgs
ls *.jpg | sed -e 's/\.jpg$//' | xargs -I {} convert {}.jpg'[1200x1200]' ../imgs/{}.jpg
ls *.jpg | sed -e 's/\.jpg$//' | xargs -I {} convert {}.jpg'[250x250]' ../thumbs/{}.jpg
cd ..
ls imgs/*.jpg | xargs magick identify > dims.txt
python3 ../make_json.py info.csv dims.txt > $1.json

echo "time to confirm"
read yes

if [ $yes == "y" ]
then
   echo "yeah we doing it"
   cd imgs
   ls *.jpg | xargs -I {} cp {} ../../../public/imgs/{}
   cd ..
   cd thumbs
   ls *.jpg | xargs -I {} cp {} ../../../public/thumbs/{}
   cd ../../
   python3 commit.py $1/$1.json ../src/artinfo.json
fi

This was all well and good for the last few years, but today my script wasn’t working. In iOS 17, photos sent via AirDrop from an iPhone to a Mac end in .HEIC (not .heic). Yes, my scripts could account for the fact that either capitalization scheme could be used, but that’s not the point. Why was this change inside iOS made? I don’t know, it doesn’t matter, but I’d like a $5 Apple gift card in exchange for the minutes I lost today.



[1] The site was originally hosted as an App Engine app written in Python, where the only purpose of the server was to trivially manipulate a static file containing metadata about the images on the site. The code was not saved in git, and the App Engine SDK was only installed on an Intel NUC in my closet that wasn’t usually connected to a monitor. To update the site, I’d plug the NUC into my TV, fiddle with things for 30 minutes on a horribly scaled Windows UI on a 4K TV, and put the NUC back in the closet.

[2] There’s maybe another post here about how ChatGPT saved me from going insane when I once invoked sh update.sh 7_6_2023 00408 and was surprised with what happened, but that’s besides the point.