Chinaunix首页 | 论坛 | 博客
  • 博客访问: 533603
  • 博文数量: 78
  • 博客积分: 1913
  • 博客等级: 上尉
  • 技术积分: 829
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-14 21:29
文章分类

全部博文(78)

文章存档

2011年(27)

2010年(26)

2009年(20)

2008年(5)

我的朋友

分类:

2010-12-08 15:38:38

Mac OS X上使用shell command可以得到一个用户的头像, 如下命令生成一个jpg的头像:

dscl . -read /Users/short_username JPEGPhoto | tail -1 | xxd -r -p > /PATH/TO/accountImage.jpg


short_username 为用户名.

当然, 如果图像是mac自带的话, 用如下命令便可以得到头像的地址:

dscl . -read /Users/short_username Picture


参考:

Mac OS X 10.5+ stores user's account pictures within the Directory Service with the exception of an account that has not modified their user picture from when first created. When first created an account contains a 'Picture' attribute in their user record that is a path to the image in question. This can be read using the dscl command (dscl . -read /Users/short_username Picture).

If a user has modified their user picture at any time the account picture (aka cropped version if appropriate) is stored in the 'JPEGPhoto' attribute of their user record.

Original files can be found at /Library/User Pictures if you're looking for an Apple provided picture, while your personal original files should be found at ~/Library/Images/iChat Recent Pictures/. If the files are ever removed from the iChat Recent Pictures folder it will not affect your user account's image whatsoever.

If you wish to extract a 320x320 version of your account picture you can do so by running the following command: dscl . -read /Users/short_username JPEGPhoto | tail -1 | xxd -r -p > /PATH/TO/accountImage.jpg

If you are running Mac OS X 10.4, my memory is failing me as I don't recall if the user picture was stored in NetInfo or not.



阅读(2905) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~