Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 897

超實用!前端(網頁)開發小工具:假文、假圖與AI臉孔

$
0
0

01|900

1. 隨機圖片(假圖)API

網址:https://picsum.photos/

  1. 正方形圖片:https://picsum.photos/寬
  2. 矩形圖片:https://picsum.photos/寬/高
  3. 確保取到不同的圖:附加 ?random=數字
  4. 取灰階圖:附加 ?grayscale
  5. 模糊化:附加 ?blur

2. AI臉孔(假臉)API

網址:https://generated.photos/
❗需要申請API Key,免費版每月只能調用50次

2.1. 網址選項

  • 說明:https://generated.photos/account#apikey
選項 能使用的值
emotion (情緒) joy, neutral, surprise
gender (性別) male, female
age (年齡) infant, child, young-adult, adult, elderly
ethnicity (種族) white, latino, asian, black
eye_color (朣孔顏色) brown, blue, gray, green
hair_color (髮色) brown, blond, black, gray, red
hair_length (頭髮長度) short, medium, long
order_by (排序) latest, oldest, random, Default: latest.
page (頁數) 取回的頁數,預設是1
per_page (每頁個數) 最大100,預設10

2.2. API使用範例

<script>
  async function getFace() {
    // gender=female
    let response = await fetch("https://api.generated.photos/api/v1/faces?api_key=申請的Key&per_page=3&order_by=random", {
      method: "GET"
    });
    let result = await response.json();
    document.getElementById("img1").src = result.faces[0].urls[4]["512"];
    document.getElementById("img2").src = result.faces[1].urls[4]["512"];
    document.getElementById("img3").src = result.faces[2].urls[4]["512"];
  }

  getFace();
</script>

3. 免費AI臉孔網站與API

網站:https://100k-faces.glitch.me/
說明:ozgrozer/100k-faces: API for 100,000 AI generated faces
圖片來源:https://generated.photos

3.1. 使用方法

  1. 直接存取隨機圖片 /random-image
<img src="https://100k-faces.glitch.me/random-image" />
  1. 取回帶有圖片網址的JSON回應: https://100k-faces.glitch.me/random-image-url
{"url":"https://ozgrozer.github.io/100k-faces/0/1/001343.jpg"}

4. 免費臉孔網站與API

網址: https://randomuser.me/
說明: https://randomuser.me/documentation#howto

4.1. 網址選項

選項 能使用的值
results 圖片個數
gender (性別) male, female
format json(預設), PrettyJSON或pretty, csv, yaml, xml
<script>
  async function getFace() {
    // gender=female
    let response = await fetch("https://randomuser.me/api/?results=3", {
      method: "GET"
    });
    let result = await response.json();
    document.getElementById("img1").src = result.results[0].picture.medium;
    document.getElementById("img2").src = result.results[1].picture.medium;
    document.getElementById("img3").src = result.results[2].picture.medium;
  }

  getFace();
</script>

5. SVG圖示

網址: https://heroicons.dev

免費的SVG圖片,方便製作按鈕的圖示。
01|700

6. 中英文假字、文章產生器

網址: http://www.richyli.com/tool/loremipsum/

7. 教學影片

##您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 897

Trending Articles