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
|
{{template "header.html" "API documentation | Mandible"}}
{{template "navbar.html"}}
{{template "modal_uploaded.html"}}
{{template "modal_error.html"}}
<div class="container">
<div class="row">
<div class="col-md-12 well">
<h1>Rest API:</h1>
<p>Interfacing with Mandible is extremely simple:</p>
<blockquote>
<h2>Upload an image file:</h2>
<p><code>POST {{.OriginUrl}}/api/v1/file</code></p>
<p>with the following multi-part/form-data</p>
<ul>
<li><code>image</code> - file</li>
</ul>
</blockquote>
<blockquote>
<h2>Upload an image from a URL:</h2>
<p><code>POST {{.OriginUrl}}/api/v1/url</code></p>
<p>with the following multi-part/form-data</p>
<ul>
<li><code>image</code> - file</li>
</ul>
</blockquote>
<blockquote>
<h2>Upload an image from base64 data:</h2>
<p><code>POST {{.OriginUrl}}/api/v1/base64</code></p>
<p>with the following multi-part/form-data</p>
<ul>
<li><code>image</code> - image encoded as base64 data</li>
</ul>
</blockquote>
<blockquote>
<h2>Thumbnail Generation:</h2>
<p>To generate thumbnails with the request, pass the following JSON as form-data, keyed under <code>thumbs</code></p>
<pre><code>{
"name1": {
"width": x,
"height": y,
"shape": ("square" | "thumb" | "circle")
},
"name2": {
"width": x2,
"height": y2,
"shape": ("square" | "thumb" | "circle")
},
...
}</code></pre>
<p>Note: Square thumbnails don't preserve aspect ratio, whereas the 'thumb' type does.</p>
</blockquote>
<h1>Example Usage:</h1>
<blockquote>
<h2>URL Upload with thumbnails:</h2>
<pre><code>curl -i {{.OriginUrl}}/api/v1/url \
-d 'image=http://i.imgur.com/s9zxmYe.jpg' \
-d 'thumbs={"small": {"width": 20, "height": 20, "shape": "square"}, "profile": {"width": 50, "height": 50, "shape": "circle"}}'</code></pre>
<h2>Response:</h2>
<pre><code>{
"data": {
"width": 380,
"height": 430,
"link": "{{.ResponseUrl}}/i/Y/h/Yhs6srW",
"mime": "image/jpeg",
"name": "",
"size": 82199,
"thumbs": {
"profile":"{{.ResponseUrl}}/t/Y/h/Yhs6srW/profile",
"small": "{{.ResponseUrl}}/t/Y/h/Yhs6srW/small"
}
},
"status": 200,
"success": true
}</pre></code>
</blockquote>
<blockquote>
<h2>File Upload with thumbnails:</h2>
<pre><code>curl -i {{.OriginUrl}}/api/v1/file \
-F 'image=@/tmp/cat.gif' \
-F 'thumbs={"small": {"width": 20, "height": 20, "shape": "square"}}'</pre></code>
<h2>Response:</h2>
<pre><code>{
"data": {
"width": 354,
"height": 200,
"link": "{{.ResponseUrl}}/i/U/v/UvfuzBW",
"mime": "image/gif",
"name": "cat.gif",
"size": 3511100,
"thumbs": {
"small":"{{.ResponseUrl}}/t/U/v/UvfuzBW/small"
}
},
"status": 200,
"success": true
}</pre></code>
</blockquote>
</div>
</div>
</div>
{{template "footer.html"}}
|