I am trying to change the user image for the photo account using these dscl commands:
sudo dscl . delete /Users/photo Picture
sudo dscl . delete /Users/photo JPEGPhoto
sudo dscl . create /Users/photo Picture "/Library/User Pictures/Halloween.psd"
sudo dscl . create /Users/photo JPEGPhoto "/Library/User Pictures/Halloween.psd"
After that I clear caches and kill cfprefsd like so:
sudo killall cfprefsd
sudo kextcache -system-caches
I have run this without killing/clearing, with the same result, which is...
After running these commands, when I logout a pinwheel appears on a black background I can still see my cursor, but then the monitor goes black and there is no cursor.
This repeats until a hard shutdown is done. It is impossible to log back in even after rebooting because I can never get to the login screen.
I tried copying off the vanilla loginwindow prefs file and replacing it after the login screen is screwed up. I tried to boot to safe mode but a normal boot appears to occur. When I boot in verbose mode it gets to the same point before login. Only while booting in verbose mode the screen flickers with the login background but then goes back to the loop, which appears to be executing more code (it looks irrelevant, like Wi-Fi settings etc.)
Information on the machines is irrelevant so I don't need to backup or restore the machine as a part of my solution.
Edit:
I have now come to the revelation that...
sudo dscl . create /Users/photo Picture "/Library/User Pictures/Halloween.psd"
Doesn't do anything. After running the command, I read back the property and it's still there. Any ideas?
Edit 2:
The solution to anyone else who is facing this issue is to add:
sudo dscl . -read /Users/photo JPEGPhoto
after deleting the JPEGPhoto key, and it works perfectly!
The JPEGPhoto attribute shouldn't be a file path, it needs to be a hexidecimal-encoded JPEG image. Take a look at the JPEGPhoto attribute for another account to get an idea what it should look like.