-
Notifications
You must be signed in to change notification settings - Fork 0
/
cld-deliver.nnb
146 lines (146 loc) · 7 KB
/
cld-deliver.nnb
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
{
"cells": [
{
"language": "markdown",
"source": [
"# Cloudinary Tranform and Deliver"
],
"outputs": []
},
{
"language": "markdown",
"source": [
"## Create Image URL and Deliver"
],
"outputs": []
},
{
"language": "typescript",
"source": [
"// create image url\nrequire('dotenv').config();\nconst cloudinary = require('cloudinary').v2;\nconsole.log(cloudinary.config().cloud_name)\nlet url = cloudinary.url('goldfish-b')\nconsole.log(url)"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"picturecloud7",
"http://res.cloudinary.com/picturecloud7/image/upload/goldfish-b",
""
]
}
]
}
]
},
{
"language": "markdown",
"source": [
"### Request image from CDN\n<img width=\"400px\" src=\"http://res.cloudinary.com/picturecloud7/image/upload/goldfish-b\" alt=\"goldfish\">"
],
"outputs": []
},
{
"language": "markdown",
"source": [
"## Create a Video URL\n\nYou need to add the `resource_type` because the default is `image`. Start with a video URL. Then create a poster and finally a video tag."
],
"outputs": []
},
{
"language": "typescript",
"source": [
"// create a video url\nrequire('dotenv').config();\nconst cloudinary = require('cloudinary').v2;\nurl = cloudinary.url('sledding-b', {resource_type:'video',format: 'mp4'})\nconsole.log(url)\n// create poster image\nconsole.log(cloudinary.url('sledding-b', {resource_type: 'video',format: 'jpg'}))\n// create a video tag\nlet video = cloudinary.video('sledding-b')\nconsole.log(video)"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"http://res.cloudinary.com/picturecloud7/video/upload/sledding-b.mp4",
"<video poster='http://res.cloudinary.com/picturecloud7/video/upload/sledding-b.jpg'><source src='http://res.cloudinary.com/picturecloud7/video/upload/sledding-b.webm' type='video/webm'><source src='http://res.cloudinary.com/picturecloud7/video/upload/sledding-b.mp4' type='video/mp4'><source src='http://res.cloudinary.com/picturecloud7/video/upload/sledding-b.ogv' type='video/ogg'></video>",
""
]
}
]
}
]
},
{
"language": "markdown",
"source": [
"### Request video from CDN\n\nIt's not possible to embed video or use video elements in markdown. Instead we'll take a frame to use as a 'poster', and add a link the opens the video in a browser window.\n\n<a href=\"http://res.cloudinary.com/picturecloud7/video/upload/sledding-b\" title=\"sledding\"><img src=\"http://res.cloudinary.com/picturecloud7/video/upload/w_400/sledding-b.jpg\" alt=\"Sledding\" /></a>\n\n\nhttp://res.cloudinary.com/picturecloud7/video/upload/sledding-b"
],
"outputs": []
},
{
"language": "markdown",
"source": [
"## Add an image effect transformation\n\nTransformations can be used to improve optimization or add aesthetic effects. In this example, we're adding an aesthetic effect."
],
"outputs": []
},
{
"language": "typescript",
"source": [
"// try cartoonify\nconsole.log(cloudinary.url('goldfish-b',{effect: \"cartoonify\"})"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"http://res.cloudinary.com/picturecloud7/image/upload/e_cartoonify/goldfish-b",
""
]
}
]
}
]
},
{
"language": "markdown",
"source": [
"### Deliver the tranformed image\n\n<img width=\"400px\" src=\"http://res.cloudinary.com/picturecloud7/image/upload/e_cartoonify/goldfish-b\" alt=\"goldfish cartoonified\">"
],
"outputs": []
},
{
"language": "markdown",
"source": [
"## Optimize an Image\n\nImage optimization can happen when you do one or more of the following;\n\n- make the image smaller\n- compress the image\n- use the optimum format for the browser requestion the image\n\nUse `q_auto` and `f_auto` to optimize the goldfish image and set the width to 400 to scale the image to a smaller size.\n\nLook at the iamge in the browser and determine the size with and without the optimization steps.\n\n\n"
],
"outputs": []
},
{
"language": "typescript",
"source": [
"console.log(cloudinary.url('goldfish-b'))\nconsole.log(cloudinary.url('goldfish-b',{width: 400, quality: 'auto', fetch_format: 'auto'}))"
],
"outputs": [
{
"items": [
{
"mime": "application/vnd.code.notebook.stdout",
"value": [
"http://res.cloudinary.com/picturecloud7/image/upload/goldfish-b",
"http://res.cloudinary.com/picturecloud7/image/upload/f_auto,q_auto,w_400/goldfish-b",
""
]
}
]
}
]
},
{
"language": "markdown",
"source": [
"#### Unoptimized Image 143K\n\n<a href=\"http://res.cloudinary.com/picturecloud7/image/upload/goldfish-b\" title=\"sledding\"><img width=\"400px\" src=\"http://res.cloudinary.com/picturecloud7/image/upload/goldfish-b\" alt=\"unoptimized\" /></a>\n\n\n#### Optimzed Image 8K\n\n<a href=\"http://res.cloudinary.com/picturecloud7/image/upload/f_auto,q_auto,w_400/goldfish-b\" title=\"sledding\"><img width=\"400px\" src=\"http://res.cloudinary.com/picturecloud7/image/upload/f_auto,q_auto,w_400/goldfish-b\" alt=\"optimized\" /></a>\n\n"
],
"outputs": []
}
]
}