Sometimes, you may want to programmatically set a default user picture (with the option for the user to change it later to a picture of her own choice).
You used to be able to delete the JPEGPhoto
attribute and just add in a Picture
attribute, but that seems to have broken somewhere between October 2018 and September 2019.
In macOS 10.14.6, if you use dscl
to delete the JPEGPhoto
attribute, and then add in a Picture
attribute, you’ll see one of the user pictures change, but the other one will default to the generic silhouette:
Unfortunately, you also can’t just script writing in the hex of the photo via a dscl . -create /Users/username JPEGPhoto ALLOFTHEHEXTEXT
command. You will get a /usr/bin/dscl: Argument list too long
error.
Someone on Stack Exchange managed to find a solution using dsimport
.
Note: I did some further testing, and you may need to first run
sudo dscl . delete /Users/username JPEGPhoto
sudo dscl . delete /Users/username Picture
before successfully running the script linked to above.
If you run that script, you’ll see it changes both photos.
This script works for now in 10.14.6, and it also works in Catalina beta build 19A578c.
Leave a Reply