本文整理汇总了Python中thumbor.url.Url.generate_options方法的典型用法代码示例。如果您正苦于以下问题:Python Url.generate_options方法的具体用法?Python Url.generate_options怎么用?Python Url.generate_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thumbor.url.Url
的用法示例。
在下文中一共展示了Url.generate_options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_usage_new_format
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_usage_new_format():
key = "my-security-key"
image = "s.glbimg.com/et/bb/f/original/2011/03/24/VN0JiwzmOw0b0lg.jpg"
thumbor_signer = Signer(key)
thumbor_url = Url.generate_options(
width=300,
height=200,
smart=True,
adaptive=False,
fit_in=False,
horizontal_flip=False,
vertical_flip=False,
halign='center',
valign='middle',
crop_left=0,
crop_top=0,
crop_right=0,
crop_bottom=0,
filters=[]
)
thumbor_url = ('%s/%s' % (thumbor_url, image)).lstrip('/')
thumbor_url = '/%s/%s' % (thumbor_signer.signature(thumbor_url), thumbor_url)
crypto = CryptoURL(key=key)
url = crypto.generate(
width=300,
height=200,
smart=True,
image_url=image
)
assert url == thumbor_url
示例2: test_url_generate_with_alignments
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_alignments():
url = Url.generate_options(
halign='left',
valign='top'
)
assert url == "0x0/left/top", url
示例3: test_can_generate_url
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_can_generate_url(self):
url = Url.generate_options(
debug=True,
width=300,
height=200,
smart=True,
meta=True,
trim=True,
adaptive=True,
full=True,
fit_in=True,
horizontal_flip=True,
vertical_flip=True,
halign='left',
valign='top',
crop_left=100,
crop_top=100,
crop_right=400,
crop_bottom=400,
filters='brightness(100)'
)
expect(url).to_equal(
'debug/meta/trim/100x100:400x400/adaptive-full-fit-in/-300x-200/left/top/smart/filters:brightness(100)'
)
示例4: test_url_generate_min
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_min():
url = Url.generate_options(
width=300,
height=200
)
assert url == "300x200"
示例5: encrypt
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def encrypt(self,
width,
height,
smart,
fit_in,
flip_horizontal,
flip_vertical,
halign,
valign,
crop_left,
crop_top,
crop_right,
crop_bottom,
image):
url = "%s/%s" % (Url.generate_options(width,
height,
smart,
False,
fit_in,
flip_horizontal,
flip_vertical,
halign,
valign,
crop_left,
crop_top,
crop_right,
crop_bottom),
hashlib.md5(image).hexdigest())
pad = lambda s: s + (16 - len(s) % 16) * "{"
cipher = AES.new(self.salt)
encrypted = base64.urlsafe_b64encode(cipher.encrypt(pad(url)))
return encrypted
示例6: test_url_generate_with_smart
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_smart():
url = Url.generate_options(
width=300,
height=200,
smart=True
)
assert url == "300x200/smart"
示例7: test_url_generate_with_flipping
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_flipping():
url = Url.generate_options(
width=300,
height=200,
smart=True,
horizontal_flip=True,
vertical_flip=True
)
assert url == "-300x-200/smart"
示例8: test_url_generate_with_manual_crop
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_manual_crop():
url = Url.generate_options(
width=300,
height=200,
crop_left=10,
crop_top=11,
crop_right=12,
crop_bottom=13
)
assert url == "10x11:12x13/300x200"
示例9: test_complete_url
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_complete_url():
url = Url.generate_options(
width=300,
height=200,
smart=True,
meta=True,
horizontal_flip=True,
vertical_flip=True,
crop_left=10,
crop_top=11,
crop_right=12,
crop_bottom=13
)
assert url == "meta/10x11:12x13/-300x-200/smart", url
示例10: encrypt
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def encrypt(self,
width,
height,
smart,
adaptive,
full,
fit_in,
flip_horizontal,
flip_vertical,
halign,
valign,
trim,
crop_left,
crop_top,
crop_right,
crop_bottom,
filters,
image):
generated_url = Url.generate_options(
width=width,
height=height,
smart=smart,
meta=False,
adaptive=adaptive,
full=full,
fit_in=fit_in,
horizontal_flip=flip_horizontal,
vertical_flip=flip_vertical,
halign=halign,
valign=valign,
trim=trim,
crop_left=crop_left,
crop_top=crop_top,
crop_right=crop_right,
crop_bottom=crop_bottom,
filters=filters
)
url = "%s/%s" % (generated_url, hashlib.md5(image).hexdigest())
def pad(s):
return s + (16 - len(s) % 16) * "{"
cipher = AES.new(self.security_key, MODE_ECB)
encrypted = base64.urlsafe_b64encode(cipher.encrypt(pad(url.encode('utf-8'))))
return encrypted
示例11: encrypt
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def encrypt(
self,
width,
height,
smart,
adaptive,
fit_in,
flip_horizontal,
flip_vertical,
halign,
valign,
crop_left,
crop_top,
crop_right,
crop_bottom,
filters,
image,
):
url = "%s/%s" % (
Url.generate_options(
width=width,
height=height,
smart=smart,
meta=False,
adaptive=adaptive,
fit_in=fit_in,
horizontal_flip=flip_horizontal,
vertical_flip=flip_vertical,
halign=halign,
valign=valign,
crop_left=crop_left,
crop_top=crop_top,
crop_right=crop_right,
crop_bottom=crop_bottom,
filters=filters,
),
hashlib.md5(image).hexdigest(),
)
pad = lambda s: s + (16 - len(s) % 16) * "{"
cipher = AES.new(self.security_key)
encrypted = base64.urlsafe_b64encode(cipher.encrypt(pad(url.encode("utf-8"))))
return encrypted
示例12: test_default_url
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_default_url():
url = Url.generate_options()
assert url == "0x0"
示例13: test_url_generate_with_meta
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_url_generate_with_meta():
url = Url.generate_options(
meta=True
)
assert url == "meta/0x0"
示例14: test_can_generate_url_with_defaults
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_can_generate_url_with_defaults(self):
url = Url.generate_options()
expect(url).to_be_empty()
示例15: test_can_generate_url_with_fitin
# 需要导入模块: from thumbor.url import Url [as 别名]
# 或者: from thumbor.url.Url import generate_options [as 别名]
def test_can_generate_url_with_fitin(self):
url = Url.generate_options(fit_in=True, adaptive=False, full=False)
expect(url).to_equal('fit-in')