戴兜

戴兜

Coding the world.
github
bilibili
twitter

Placeholder Image Generation API (DouAPI)

Placeholder Image.png

Introduction to DouAPI#

DouAPI is a service provided by Dai Dou since the end of 2015. According to Uptimerobot's monitoring data, the availability rate has been above 90% for about 3 years. It can be said that DouAPI is the most dedicated project maintained by Dai Dou. During the winter vacation, DouAPI was rewritten in NodeJS, and several basic interfaces have been remade. Development is still ongoing.

What is a Placeholder Image#

When we are laying out web pages, sometimes we need to place some placeholder images to temporarily fill in the gaps. It can be quite cumbersome to manually generate these placeholder images, especially when the dimensions need to be precise to the pixel. The placeholder image generation interface provided by Dai Dou can easily solve this problem.

How to Use#

Currently, Dai Dou's website is fully HTTPS, and so is DouAPI. You can only make API requests through HTTPS.

API URL: https://api.daidr.me/apis/imgholder/[size](.[image format])?text=[custom text]&bg=[background color]&fg=[foreground color]

Parameters marked with * are required.

Size*: The size of the generated placeholder image, in the format **[width]x[height]**. The maximum size is **3000x3000**, and anything larger will return a 404 error.

**Image format**: The format of the generated image. Supported formats are webp/png/jpg/jpeg/gif, with webp being the default.

**Custom text**: The text to be displayed inside the image. The default is the image size.

**Background color**: The custom background color of the image, in hexadecimal color code. Supports 3-digit shorthand (e.g. fff) and 8-digit transparency (e.g. ffffff2c). Do not include the **#** symbol.

**Foreground color**: The custom text color. Same format as **background color**.

Simple examples:

https://api.daidr.me/apis/imgholder/100x100

https://api.daidr.me/apis/imgholder/100x100.png

https://api.daidr.me/apis/imgholder/100x100?text=custom

https://api.daidr.me/apis/imgholder/100x100?bg=a0dad0&fg=709891

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.