本文整理匯總了Python中catsnap.image_truck.ImageTruck.new_from_image方法的典型用法代碼示例。如果您正苦於以下問題:Python ImageTruck.new_from_image方法的具體用法?Python ImageTruck.new_from_image怎麽用?Python ImageTruck.new_from_image使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類catsnap.image_truck.ImageTruck
的用法示例。
在下文中一共展示了ImageTruck.new_from_image方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: reprocess_image
# 需要導入模塊: from catsnap.image_truck import ImageTruck [as 別名]
# 或者: from catsnap.image_truck.ImageTruck import new_from_image [as 別名]
def reprocess_image(request_format, image_id):
session = Client().session()
image = session.query(Image).filter(Image.image_id == image_id).one()
truck = ImageTruck.new_from_image(image)
contents = ImageContents(image_id=image.image_id, contents=truck.contents, content_type=truck.content_type)
session.add(contents)
session.flush()
delay(g.queued_tasks, process_image, contents.image_contents_id)
if request_format == "json":
return {"status": "ok"}
else:
return redirect(url_for("show_image", image_id=image.image_id))
示例2: test_new_from_image
# 需要導入模塊: from catsnap.image_truck import ImageTruck [as 別名]
# 或者: from catsnap.image_truck.ImageTruck import new_from_image [as 別名]
def test_new_from_image(self, subprocess, MockClient):
subprocess.check_output.return_value = \
'space-centurion.png: PNG image data, 1280 x 800, ' \
'8-bit/color RGB, non-interlaced'
def get_contents_to_filename(filename):
with open(filename, 'w') as fh:
fh.write('brain, skull, etc')
key = Mock()
key.get_contents_to_filename.side_effect = get_contents_to_filename
bucket = Mock()
bucket.get_key.return_value = key
client = Mock()
client.bucket.return_value = bucket
MockClient.return_value = client
image = Image(filename='faceface')
truck = ImageTruck.new_from_image(image)
eq_(truck.contents, 'brain, skull, etc')
bucket.get_key.assert_called_with('faceface')