web前端開發 - 網頁端使用PHP產生隨機的帳戶圖片?

來源:互聯網
上載者:User
網頁端使用PHP產生隨機的帳戶圖片,各位有木有知道方法或者類似的php庫,就是產生類似秘密APP的隨機頭像一樣

回複內容:

網頁端使用PHP產生隨機的帳戶圖片,各位有木有知道方法或者類似的php庫,就是產生類似秘密APP的隨機頭像一樣

正好在知乎也看到類似問題,做回搬運工。http://www.zhihu.com/question/26387811

原作者:方自在

這種頭像被稱作 Identicon, Don Park 在2007年1月18日首次想出了這個創意。

一般來說在這些網站上面如果你沒有指定自己的頭像,網站會使用 Gravatar 或者使用 Identicon (Gravatar也有相關服務) 作為預設頭像。

Identicon 是 Hash 值的可視化表示,常見的產生方法是根據 IP 位址或 email 地址產生。 伺服器通過 Identicon 可以以頭像的形式來分辨使用者,這種方法同時能夠保護使用者的隱私。

最初的 Identicon 是由9塊構成的圖形,後來它的表現形式由第三方擴充至了各種圖形形式。

相關詳細介紹參考下面的Wiki連結,其他參考為各語言開源實現。

PS

gravatar 和 wordpress 是一家公司的。比如我的頭像

每當我在支援 gravatar 的網站(比如 wordpress)評論時,只要留下我的郵箱,就會顯示這個頭像。

參考:

  • Wikipedia: Identicon
  • Original Identicon Java and canvas implementations: donpark/identicon
  • Java Mavenized version: pauloubuntu/identicon
  • PHP: yzalis/Identicon
  • Go: cupcake/sigil
  • WordPress: WP_Identicon :: Dammit Jim!

更多語言請搜尋Github:https://github.com/search?utf8=%E2%9C%93&q=identicon

可以用一個php檔案,就隨機產生avatar,僅僅需要附上兩個參數hash 和 size

示範地址:http://app.ispu.cn/identicon/

用到的組建檔案在這裡https://github.com/chloetina/random_avatar

這幾個你看如何?
https://github.com/yzalis/Identicon
http://www.splitbrain.org/projects/monsterid
http://francisshanahan.com/index.php/identicon5/
https://github.com/seyDoggy/placeholder

http://www.gravatar.com/avatar/md5?s=size&d=dtype

你也可以自己製作一組帳戶圖片放在網站/圖片/帳戶圖片目錄下,然後php讀取該目錄片檔案,產生一個列表,然後使用隨機數擷取列表中的一個圖片並返回給前端

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.