forked from Ovi/DummyJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs-image.ejs
More file actions
209 lines (186 loc) · 9.04 KB
/
docs-image.ejs
File metadata and controls
209 lines (186 loc) · 9.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html lang="en">
<!-- header -->
<%- include('./partials/docs-head') %>
<body>
<!-- header -->
<%- include('./partials/header') %>
<!-- side-nav -->
<%- include('./partials/docs-side-nav') %>
<section>
<div class="content">
<h1 class="docs-title">
<img src="/public/img/icons/image.svg" class="icon" alt="svg icon" /> Image - Docs
</h1>
<p class="display-para">
The <strong>image</strong> endpoint provides customizable placeholder images by specifying size in the URL, with options for background color, text color, and display text, ideal for use in websites and wireframes.
</p>
<div class="resource">
<p class="res-tip">
The base URL is: <strong><a href="https://dummyjson.com/image">dummyjson.com/image</a></strong>
</p>
</div>
<div class="resource" id="image-square">
<a href="#image-square" class="res-title">Generate square image</a>
<pre><code class="language-js">
// https://dummyjson.com/image/SIZE
fetch('https://dummyjson.com/image/150')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/150" alt="150x150" />
</div>
</div>
<div class="resource" id="image-custom-size">
<a href="#image-custom-size" class="res-title">Generate custom size image</a>
<pre><code class="language-js">
// https://dummyjson.com/image/WIDTHxHEIGHT
fetch('https://dummyjson.com/image/200x100')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/200x100" alt="200x100" />
</div>
</div>
<div class="resource" id="image-custom-text">
<a href="#image-custom-text" class="res-title">Generate image with custom text</a>
<pre><code class="language-js">
// https://dummyjson.com/image/SIZE/?text=TEXT
fetch('https://dummyjson.com/image/400x200/008080/ffffff?text=Hello+Peter')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/400x200/008080/ffffff?text=Hello+Peter" alt="400x200" />
</div>
</div>
<div class="resource" id="image-custom-color">
<a href="#image-custom-color" class="res-title">Generate image with custom colors</a>
<pre><code class="language-js">
// https://dummyjson.com/image/SIZE/BACKGROUND/COLOR
fetch('https://dummyjson.com/image/400x200/282828')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/400x200/282828" alt="400x200" />
</div>
</div>
<div class="resource" id="image-format">
<a href="#image-format" class="res-title">Generate image with different formats</a>
<p class="res-tip">Supported Formats:
<b>
<a target="_blank" href="https://dummyjson.com/image/400x200?type=png">png</a>,
<a target="_blank" href="https://dummyjson.com/image/400x200?type=jpg">jpeg</a>,
<a target="_blank" href="https://dummyjson.com/image/400x200?type=webp">webp</a>
</b>
</p>
<pre><code class="language-js">
// https://dummyjson.com/image/SIZE/BACKGROUND/COLOR
fetch('https://dummyjson.com/image/400x200?type=webp&text=I+am+a+webp+image')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/webp'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/400x200?type=webp&text=I+am+a+webp+image" alt="400x200" />
</div>
</div>
<div class="resource" id="image-font-family">
<a href="#image-font-family" class="res-title">Generate image with custom font family</a>
<p class="res-tip">
Supported Fonts:
<br />
<b>
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=bitter">bitter</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=cairo">cairo</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=comfortaa">comfortaa</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=cookie">cookie</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=dosis">dosis</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=gotham">gotham</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=lobster">lobster</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=marhey">marhey</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=pacifico">pacifico</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=poppins">poppins</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=quicksand">quicksand</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=qwigley">qwigley</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=satisfy">satisfy</a>,
<a target="_blank" href="https://dummyjson.com/image/250?text=Hello+Peter!&fontFamily=ubuntu">ubuntu</a>
</b>
</p>
<pre><code class="language-js">
// https://dummyjson.com/image/SIZE/BACKGROUND/COLOR
fetch('https://dummyjson.com/image/400x200/282828?fontFamily=pacifico&text=I+am+a+pacifico+font')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/400x200/282828?fontFamily=pacifico&text=I+am+a+pacifico+font" alt="400x200" />
</div>
</div>
<div class="resource" id="image-font-size">
<a href="#image-font-size" class="res-title">Generate image with custom font size</a>
<pre><code class="language-js">
// https://dummyjson.com/image/SIZE/?text=TEXT&fontSize=FONT_SIZE
fetch('https://dummyjson.com/image/400x200/008080/ffffff?text=Hello+Peter!&fontSize=16')
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/image/400x200/008080/ffffff?text=Hello+Peter!&fontSize=16" alt="400x200" />
</div>
</div>
<div class="resource" id="image-identicon">
<a href="#image-identicon" class="res-title">Generate identicon</a>
<pre><code class="language-js">
// https://dummyjson.com/icon/HASH/SIZE/?type=png (or svg)
fetch('https://dummyjson.com/icon/abc123/150') // png is default
.then(response => response.blob()) // Convert response to blob
.then(blob => {
console.log('Fetched image blob:', blob);
})
// Blob {size: SIZE, type: 'image/png'}
</code></pre>
<div class="output-image">
<h3>Output: </h3>
<img loading="lazy" src="https://dummyjson.com/icon/abc123/150" alt="identicon" />
</div>
</div>
</div>
</section>
<!-- footer -->
<%- include('./partials/docs-footer') %>
<script>
selectNavItem(window.location.hash || '#image-square');
</script>
</body>
</html>