当前位置: 首页>>代码示例>>Python>>正文


Python Image.original方法代码示例

本文整理汇总了Python中models.Image.original方法的典型用法代码示例。如果您正苦于以下问题:Python Image.original方法的具体用法?Python Image.original怎么用?Python Image.original使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Image的用法示例。


在下文中一共展示了Image.original方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import original [as 别名]
    def post(self):
        "Upload via a multitype POST message"

        img = self.request.get("img")
        # if we don't have image data we'll quit now
        if not img:
            self.redirect("/")
            return
        try:
            width = int(self.request.get("width"))
            hight = int(self.request.get("height"))
        except ValueError:
            image_content = img
        else:
            image_content = images.resize(img, width, height)

        original_content = img

        thumb_content = images.resize(img, 100, 100)

        image = Image()

        image.image = db.Blob(image_content)

        image.original = db.Blob(original_content)
        image.thumb = db.Blob(thumb_content)
        image.user = users.get_current_user()
        image.put()
        self.redirect("/")
开发者ID:jakobholmelund,项目名称:appengine-image-host,代码行数:31,代码来源:backend.py

示例2: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import original [as 别名]
 def post(self):
     "Upload via a multitype POST message"
     
     try:
         # check we have numerical width and height values
         width = int(self.request.get("width"))
         height = int(self.request.get("height"))
     except ValueError:
         # if we don't have valid width and height values
         # then just use the original image
         image_content = self.request.get("img")
     else:
         # if we have valid width and height values
         # then resize according to those values
         image_content = images.resize(self.request.get("img"), width, height)
     
     # get the image data from the form
     original_content = self.request.get("img")
     # always generate a thumbnail for use on the admin page
     thumb_content = images.resize(self.request.get("img"), 100, 100)
     
     # create the image object
     image = Image()
     # Try and create an s3 connection
     if len(awskeys.AWS_ACCESS_KEY_ID) > 0 and len(awskeys.AWS_SECRET_ACCESS_KEY) > 0:
         s3 = GoogleS3.AWSAuthConnection(awskeys.AWS_ACCESS_KEY_ID, awskeys.AWS_SECRET_ACCESS_KEY)
     else:
         s3 = None
     
     # and set the properties to the relevant values
     image.image = db.Blob(image_content)
     image.user = users.get_current_user()
     
     if s3 is None:
         # we always store the original here in case of errors
         # although it's currently not exposed via the frontend
         image.original = db.Blob(original_content)
         image.thumb = db.Blob(thumb_content)
         # store the image in the datasore
         image.put()
     else:
         # we want to store in S3, so store the data and use the key
         image.put()
         # Put the 3 different images
         s3.put(awskeys.BUCKET_NAME,str(image.key()) + "_original",original_content)
         s3.put(awskeys.BUCKET_NAME,str(image.key()) + "_thumb",thumb_content)
         s3.put(awskeys.BUCKET_NAME,str(image.key()) + "_image",image_content)
             
     
     # and redirect back to the admin page
     self.redirect('/')
开发者ID:saratpediredla,项目名称:appengine-image-host,代码行数:53,代码来源:backend.py

示例3: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import original [as 别名]
    def post(self):
        "Upload via a multitype POST message"
        
        img = self.request.get("img")

        # if we don't have image data we'll quit now
        if not img:
            self.redirect('/')
            return 
            
        # we have image data
        try:
            # check we have numerical width and height values
            width = int(self.request.get("width"))
            height = int(self.request.get("height"))
        except ValueError:
            # if we don't have valid width and height values
            # then just use the original image
            image_content = img
        else:
            # if we have valid width and height values
            # then resize according to those values
            image_content = images.resize(img, width, height)
        
        # get the image data from the form
        original_content = img
        # always generate a thumbnail for use on the admin page
        thumb_content = images.resize(img, 100, 100)
        
        # create the image object
        image = Image()
        # and set the properties to the relevant values
        image.image = db.Blob(image_content)
        # we always store the original here in case of errors
        # although it's currently not exposed via the frontend
        image.original = db.Blob(original_content)
        image.thumb = db.Blob(thumb_content)
        image.user = users.get_current_user()
                
        # store the image in the datasore
        image.put()
        # and redirect back to the admin page
        self.redirect('/')
开发者ID:Mondego,项目名称:pyreco,代码行数:45,代码来源:allPythonContent.py

示例4: post

# 需要导入模块: from models import Image [as 别名]
# 或者: from models.Image import original [as 别名]
    def post(self, key):
        checkkey = UploadRequestKeys.get(key)
        if not checkkey:
            self.error(404)
        if checkkey.expire_date < datetime.now():
            self.error(404)
        img = self.request.get("img")
        # if we don't have image data we'll quit now
        if not img:
            return None
        try:
            width = int(self.request.get("width"))
            hight = int(self.request.get("height"))
        except ValueError:
            image_content = img
        else:
            image_content = images.resize(img, width, height)

        original_content = img

        thumb_content = images.resize(img, 100, 100)

        image = Image()

        image.image = db.Blob(image_content)

        image.original = db.Blob(original_content)
        image.thumb = db.Blob(thumb_content)
        image.user = users.get_current_user()
        image.realm = RealmKeys.get(checkkey.realm_key)
        image.put()
        checkkey.delete()
        # self.response.out.write(simplejson.dumps({'img_url'::}))
        context = {
            "image": True,
            "img_url": "http://org-images.appspot.com/i/img?id=%s" % image.key(),
            "thumb_url": "http://org-images.appspot.com/i/thumb?id=%s" % image.key(),
        }
        path = os.path.join(os.path.dirname(__file__), "templates", "show_links.html")
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
开发者ID:jakobholmelund,项目名称:appengine-image-host,代码行数:43,代码来源:frontend.py


注:本文中的models.Image.original方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。