图像处理与视觉素材

PlaceDog

PlaceDog提供高质量的狗狗占位图片API服务,用户可通过指定尺寸和编号快速获取可爱的狗狗图片,适用于网站开发、设计原型等场景。

查看官方文档 ↗

接入教程

1.访问PlaceDog官网查看文档
2.在图片URL中添加所需尺寸参数
3.直接嵌入图片链接到项目中

使用requests获取随机狗狗图片

python
import requests

url = 'https://place.dog/300/200'
headers = {
    'Authorization': 'Bearer YOUR_API_KEY'
}

response = requests.get(url, headers=headers)

if response.status_code ==她們00:
    # Process the image data or URL
    print('Image fetched successfully')
    # In practice, you might save the image or use the URL
else:
    print(f'Error: {response.status_code}')
    print(response.text)

使用cURL获取指定尺寸的狗狗图片

php
<?php

$url = 'https://place.dog/640/480';
$apiKey = 'YOUR_API_KEY';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $apiKey
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($httpCode == 200) {
    // Handle successful response
    echo 'Dog image retrieved successfully.';
    // Typically you would output or save the image binary data
} else {
    echo 'Error: ' . $httpCode;
    echo $response;
}

curl_close($ch);

?>

使用Fetch API获取狗狗图片

javascript
const url = 'https://place.dog/1024/768';
const apiKey = 'YOUR_API_KEY';

fetch(url, {
    method: 'GET',
    headers: {
        'Authorization': `Bearer ${apiKey}`
    }
})
.then(response => {
    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response.blob(); // Get the image as a Blob
})
.then(imageBlob => {
    // Create an object URL for the image blob
    const imageObjectURL = URL.createObjectURL(imageBlob);
    // Use the imageObjectURL, e.g., set as img.src
    console.log('Dog image fetched successfully');
})
.catch(error => {
    console.error('Error fetching dog image:', error);
});

常见问题

如何获取API密钥?

请访问PlaceDog官方网站(https://place.dog),注册账户并在用户仪表板中生成您的API密钥。免费套餐通常提供有限的调用次数。

图片尺寸参数如何指定?

在请求URL路径中直接指定宽度和高度,格式为 https://place.dog/{width}/{height} 。例如,/300/200 获取宽300像素、高200像素的图片。

API有调用频率限制吗?

是的,为保障服务稳定,PlaceDog API对所有用户实施调用频率限制。具体限制取决于您的套餐等级(免费或付费),详情请参阅官方网站的定价与限制页面。

相似接口推荐

EC2 Image Builder

EC2 Image Builder 是一项完全托管的亚马逊云科技服务,可自动创建、管理和部署定制的安全“黄金”服务器镜像。这些镜像预装软件和配置,符合特定IT标准,并保持最新状态。

待确认
Imgbb

Imgbb 是一个简单快捷的图片托管和分享API,用户可以通过上传图片获取可分享的链接,支持隐私设置和快速集成。

待确认
PHP-Noise噪点背景生成器

PHP-Noise是一款在线噪点背景图像生成工具,能快速创建独特的噪点纹理背景,适用于网页设计和UI界面。该API提供自定义颜色、尺寸和噪点密度参数,可生成PNG格式图像。

待确认
ColourLovers

ColourLovers API提供丰富的图案、调色板和图像资源,允许开发者获取创意设计素材,支持多种格式和筛选条件,适用于设计类应用开发。

待确认