-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathaesthetics.py
More file actions
115 lines (97 loc) · 4.21 KB
/
aesthetics.py
File metadata and controls
115 lines (97 loc) · 4.21 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
import json
from logging import NOTSET, lastResort
from dotenv import load_dotenv
load_dotenv()
import cloudinary
from cloudinary.utils import cloudinary_url
# get reference to config instance, return "https" URLs by setting secure=True
config = cloudinary.config(secure=True)
print(config.cloud_name)
print(config.api_key)
# Log the configuration
# ==============================
print("**** Set up and configure the SDK:****\n",
config.cloud_name, config.api_key, "\n")
# DOCS: https://cloudinary.com/documentation/image_transformations
# Rounding
# url, options = cloudinary_url(
# "puma",
# width=300,
# height=300,
# crop="thumb",
# radius="max",
# format="png"
# )
# print("**** Rounding the corners of an asset with 1:1 aspect ratio****\nTransformation URL --> " + url, "\n")
# Borders
# url, options = cloudinary_url(
# "iguana",
# width=300,
# height=300,
# crop="fill",
# border="10px_solid_green"
# )
# print("**** Adding a green border to an asset ****\nTransformation URL --> " + url, "\n")
# Auto background color
# url, options = cloudinary_url(
# "llama",
# width=400,
# height=400,
# crop="pad",
# background="auto"
# )
# print("**** Adding an automatic background color to a padded crop, based on one or more predominant colors in the asset****\nTransformation URL --> " + url, "\n")
# Color effect
# url, options = cloudinary_url(
# "cld-sample",
# height=300,
# crop="scale",
# quality="auto",
# effect="tint:40:gold"
# )
# print("**** Add Color Effect ****\nTransformation URL --> " + url, "\n")
# Improve effect
# url, options = cloudinary_url(
# "i-love-ants",
# height=400,
# crop="scale",
# effect="improve:outdoor"
# )
# print("**** Improve effect for an outdoor asset ****\nTransformation URL --> " + url, "\n")
# Artistic filter
# url, options = cloudinary_url(
# "cld-sample",
# height=800,
# crop="scale",
# effect="art:zorro")
# print("**** Add the artistic effect, zorro ****\nTransformation URL --> " + url, "\n")
# Overlays - Text over image
# url, options = cloudinary_url("cld-sample",
# transformation=[
# {'crop': 'fill', 'width': 800},
# {'quality': 'auto'},
# {'color': "#FFFFFF", 'overlay': {'font_family': "arial", 'font_size': 50, 'font_weight': "bold",
# 'text_decoration': "underline", 'letter_spacing': 3, 'text': "Dalmation!"}},
# {'flags': "layer_apply",
# 'gravity': "north_east", 'y': 10, 'x': 10}
# ])
# print("**** Overlay - Transform to add text over image in the top right corner ****\nTransformation URL --> " + url, "\n")
# Overlays - Image over video
url, options = cloudinary_url("tortoise", resource_type="video",
transformation=[
{'crop': 'fill', 'width': 500},
{'overlay': 'cld-training-logo'},
{'flags': "layer_apply", 'gravity': "north_east", 'y': 10, 'x': 10, 'width':100, 'opacity':50},
{'quality': 'auto'}
])
print("**** Overlay - Transform to add a Cloudinary logo overlay to the north east corner of an video ****\nTransformation URL --> " + url, "\n")
# Overlays - Image over video (same as previous example, but using Video tag)
# video_overlay = cloudinary.CloudinaryVideo("tortoise").video(transformation=[
# {'crop': 'fill', 'width': 500},
# {'quality': 'auto'},
# {'overlay': 'cld-training-logo'},
# {'opacity': 50},
# {'width': 100},
# {'flags': "layer_apply", 'gravity': "north_east", 'y': 10, 'x': 10}
# ])
# print("**** Overlay - Transform to add a Cloudinary logo overlay to the north east corner of an video ****\nTransformation URL --> " + video_overlay, "\n")