コード例 #1
0
 def setCropping(self, x, y, width, height):
    checkParamsType([(x, [int]), (y, [int]), (height, [int]), (width, [int])])
    checkParamsLimit([(x, ['0<=x<=10000']), (y, ['0<=x<=10000']), (height, ['0<=x<=10000']), (width, ['0<=x<=10000'])])
    self.__args['cut_x'] = x
    self.__args['cut_y'] = y
    self.__args['cut_h'] = height
    self.__args['cut_w'] = width
コード例 #2
0
 def setSource(self, image_source):
    checkParamsType([(image_source, [basestring])])
    if isinstance(image_source, unicode):
       image_source = image_source.encode('utf-8')
    checkParamsLimit([(image_source, ['0<len(x)<=2048'])])
    if self._isUrl(image_source):
       self.__args['src'] = image_source
コード例 #3
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setAnnotatePos(self, x_offset, y_offset):
     checkParamsType([(x_offset, [int])])
     checkParamsLimit([(x_offset, ['x>=0'])])
     checkParamsType([(y_offset, [int])])
     checkParamsLimit([(y_offset, ['x>=0'])])
     self.__operations['x_offset'] = x_offset
     self.__operations['y_offset'] = y_offset
コード例 #4
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def _checkRGB(self, rgbstr):
     checkParamsType([(rgbstr, [basestring])])
     if isinstance(rgbstr, unicode):
         rgbstr = rgbstr.encode('utf-8')
     checkParamsLimit([(rgbstr, ['len(x)==6'])])
     if not self.RGB_PATTERN.match(rgbstr):
         raise BaeValueError("invalid RGB color", rgbstr)
コード例 #5
0
 def _checkRGB(self, rgbstr):
    checkParamsType([(rgbstr, [basestring])])
    if isinstance(rgbstr, unicode):
       rgbstr = rgbstr.encode('utf-8')
    checkParamsLimit([(rgbstr, ['len(x)==6'])])
    if not self.RGB_PATTERN.match(rgbstr):
       raise BaeValueError("invalid RGB color", rgbstr)
コード例 #6
0
 def setAnnotatePos(self, x_offset, y_offset):
    checkParamsType([(x_offset, [int])])
    checkParamsLimit([(x_offset, ['x>=0'])])
    checkParamsType([(y_offset, [int])])
    checkParamsLimit([(y_offset, ['x>=0'])])
    self.__operations['x_offset'] = x_offset
    self.__operations['y_offset'] = y_offset
コード例 #7
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCompositeCanvas(self, canvas_width, canvas_height):
     checkParamsType([(canvas_width, [int])])
     checkParamsLimit([(canvas_width, ['0<=x<=10000'])])
     checkParamsType([(canvas_height, [int])])
     checkParamsLimit([(canvas_height, ['0<=x<=10000'])])
     self.__composite_canvas_width = canvas_width
     self.__composite_canvas_height = canvas_height
コード例 #8
0
 def setCompositeCanvas(self, canvas_width, canvas_height):
    checkParamsType([(canvas_width, [int])])
    checkParamsLimit([(canvas_width, ['0<=x<=10000'])])
    checkParamsType([(canvas_height, [int])])
    checkParamsLimit([(canvas_height, ['0<=x<=10000'])])
    self.__composite_canvas_width = canvas_width
    self.__composite_canvas_height = canvas_height
コード例 #9
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setSource(self, image_source):
     checkParamsType([(image_source, [basestring])])
     if isinstance(image_source, unicode):
         image_source = image_source.encode('utf-8')
     checkParamsLimit([(image_source, ['0<len(x)<=2048'])])
     if self._isUrl(image_source):
         self.__args['src'] = image_source
コード例 #10
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCompositeOpacity(self, opacity, img_key=0):
     checkParamsType([(opacity, [int, float])])
     checkParamsLimit([(opacity, ['0.0<=x<=1.0'])])
     if img_key >= len(self.__strudata['req_data_source']):
         raise BaeValueError("invalid img_key, image %d isn't exist" %
                             img_key)
     self.__strudata['req_data_source'][img_key]['operations'][
         'opacity'] = opacity
コード例 #11
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCompositeAnchor(self, anchor, img_key=0):
     checkParamsType([(anchor, [int])])
     checkParamsLimit([(anchor, ['0<=x<=8'])])
     if img_key >= len(self.__strudata['req_data_source']):
         raise BaeValueError("invalid img_key, image %d isn't exist" %
                             img_key)
     self.__strudata['req_data_source'][img_key]['operations'][
         'anchor_point'] = anchor
コード例 #12
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCropping(self, x, y, width, height):
     checkParamsType([(x, [int]), (y, [int]), (height, [int]),
                      (width, [int])])
     checkParamsLimit([(x, ['0<=x<=10000']), (y, ['0<=x<=10000']),
                       (height, ['0<=x<=10000']), (width, ['0<=x<=10000'])])
     self.__args['cut_x'] = x
     self.__args['cut_y'] = y
     self.__args['cut_h'] = height
     self.__args['cut_w'] = width
コード例 #13
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setTranscoding(self, image_type, quality=60):
     types = {'gif': 2, 'jpg': 1, 'png': 3, 'webp': 4}
     checkParamsType([(image_type, [basestring]), (quality, [int])])
     checkParamsLimit([(quality, ['0<=x<=100'])])
     try:
         self.__args['imgtype'] = types[image_type]
     except KeyError:
         raise BaeParamError('Invalid Image Type[%s]' % image_type)
     if image_type in ['gif', 'jpg']:
         self.__args['quality'] = quality
コード例 #14
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def generateVCode(self, vcode_len=4, vcode_pattern=0):
     checkParamsType([(vcode_len, [int])])
     checkParamsLimit([(vcode_len, ['4<=x<=5'])])
     checkParamsType([(vcode_pattern, [int])])
     checkParamsLimit([(vcode_pattern, ['0<=x<=3'])])
     self.__args = {}
     self.__args['vcservice'] = 0
     self.__args['len'] = vcode_len
     self.__args['setno'] = vcode_pattern
     return self._common_process(self.__args)
コード例 #15
0
 def generateVCode(self, vcode_len = 4, vcode_pattern = 0):
    checkParamsType([(vcode_len, [int])])
    checkParamsLimit([(vcode_len, ['4<=x<=5'])])
    checkParamsType([(vcode_pattern, [int])])
    checkParamsLimit([(vcode_pattern, ['0<=x<=3'])])
    self.__args = {}
    self.__args['vcservice'] = 0
    self.__args['len'] = vcode_len
    self.__args['setno'] = vcode_pattern
    return self._common_process(self.__args)
コード例 #16
0
 def setTranscoding(self, image_type, quality = 60):
    types = {'gif': 2, 'jpg': 1, 'png': 3, 'webp': 4}
    checkParamsType([(image_type, [basestring]), (quality, [int])])
    checkParamsLimit([(quality, ['0<=x<=100'])])
    try:
       self.__args['imgtype'] = types[image_type]
    except KeyError:
       raise BaeParamError('Invalid Image Type[%s]'%image_type)
    if image_type in ['gif', 'jpg']:
       self.__args['quality'] = quality
コード例 #17
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setAnnotateOpacity(self, opacity):
     checkParamsType([(opacity, [int, float])])
     checkParamsLimit([(opacity, ['0.0<=x<=1.0'])])
     if opacity == 1:
         opacity = '00'
     elif opacity == 0:
         opacity = 'ff'
     else:
         opacity = hex(int(math.ceil(255 - opacity * 255)))
         opacity = opacity.replace('0x', '')
     opacity = opacity.upper()
     self.__operations['opacity'] = opacity
コード例 #18
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setAnnotateFont(self, name, size, color):
     checkParamsType([(name, [int])])
     checkParamsLimit([(name, ['0<=x<=4'])])
     checkParamsType([(size, [int])])
     checkParamsLimit([(size, ['0<=x<=100'])])
     checkParamsType([(color, [basestring])])
     if isinstance(color, unicode):
         color = color.encode('utf-8')
     self._checkRGB(color)
     self.__operations['font_name'] = name
     self.__operations['font_size'] = size
     self.__operations['font_color'] = color
コード例 #19
0
 def setAnnotateFont(self, name, size, color):    
    checkParamsType([(name, [int])])
    checkParamsLimit([(name, ['0<=x<=4'])])
    checkParamsType([(size, [int])])
    checkParamsLimit([(size, ['0<=x<=100'])])
    checkParamsType([(color, [basestring])])
    if isinstance(color, unicode):
       color = color.encode('utf-8')
    self._checkRGB(color)
    self.__operations['font_name'] = name
    self.__operations['font_size'] = size
    self.__operations['font_color'] = color
コード例 #20
0
 def setAnnotateOpacity(self, opacity):
    checkParamsType([(opacity, [int, float])])
    checkParamsLimit([(opacity, ['0.0<=x<=1.0'])])
    if opacity == 1:
       opacity = '00'
    elif opacity == 0:
       opacity = 'ff'
    else:
       opacity = hex(int(math.ceil(255 - opacity*255)))
       opacity = opacity.replace('0x', '')
    opacity = opacity.upper()
    self.__operations['opacity'] = opacity
コード例 #21
0
 def __init__(self, access_key, secret_key, host, image_source = "http://", debug = False):
    self.__args = {}
    self.__args['src'] = image_source
    self.__ak = access_key 
    self.__sk = secret_key
    self.__host = host
    checkParamsType([(self.__ak, [basestring]), (self.__sk, [basestring]), (debug, [bool]), (self.__args['src'], [basestring]), (self.__host, [basestring])])
    checkParamsLimit([(image_source, ['0<=len(x)<=2048'])])
    if not self.__ak or not self.__sk or not self.__host:
       raise BaeConstructError("Invalid ak, sk, or image host")
    self.__requestId = 0
    self._debug = debug
    self.__strudata = None
コード例 #22
0
 def verifyVCode(self, vcode_input, vcode_secret):
    checkParamsType([(vcode_input, [basestring])])
    if isinstance(vcode_input, unicode):
       vcode_input = vcode_input.encode('utf-8')
    checkParamsLimit([(vcode_input, ['4<=len(x)<=5'])])
    checkParamsType([(vcode_secret, [basestring])])
    if isinstance(vcode_secret, unicode):
       vcode_secret = vcode_secret.encode('utf-8')
    self.__args = {}
    self.__args['vcservice'] = 1
    self.__args['input'] = vcode_input
    self.__args['vcode'] = vcode_secret
    return self._common_process(self.__args)
コード例 #23
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def verifyVCode(self, vcode_input, vcode_secret):
     checkParamsType([(vcode_input, [basestring])])
     if isinstance(vcode_input, unicode):
         vcode_input = vcode_input.encode('utf-8')
     checkParamsLimit([(vcode_input, ['4<=len(x)<=5'])])
     checkParamsType([(vcode_secret, [basestring])])
     if isinstance(vcode_secret, unicode):
         vcode_secret = vcode_secret.encode('utf-8')
     self.__args = {}
     self.__args['vcservice'] = 1
     self.__args['input'] = vcode_input
     self.__args['vcode'] = vcode_secret
     return self._common_process(self.__args)
コード例 #24
0
 def setCompositeSource(self, image_source):
    checkParamsType([(image_source, [basestring])])
    if isinstance(image_source, unicode):
       image_source = image_source.encode('utf-8')
    checkParamsLimit([(image_source, ['0<=len(x)<=2048'])])
    t = {'http_reqpack': {},
         'source_data_type': '1',
         'operations': {},
        }
    if self._isUrl(image_source):
       t['sourcemethod'] = 'GET'
       t['source_url'] = image_source 
       self.__strudata['req_data_source'].append(t)
    else: pass
コード例 #25
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCompositeSource(self, image_source):
     checkParamsType([(image_source, [basestring])])
     if isinstance(image_source, unicode):
         image_source = image_source.encode('utf-8')
     checkParamsLimit([(image_source, ['0<=len(x)<=2048'])])
     t = {
         'http_reqpack': {},
         'source_data_type': '1',
         'operations': {},
     }
     if self._isUrl(image_source):
         t['sourcemethod'] = 'GET'
         t['source_url'] = image_source
         self.__strudata['req_data_source'].append(t)
     else:
         pass
コード例 #26
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def __init__(self,
              access_key,
              secret_key,
              host,
              image_source="http://",
              debug=False):
     self.__args = {}
     self.__args['src'] = image_source
     self.__ak = access_key
     self.__sk = secret_key
     self.__host = host
     checkParamsType([(self.__ak, [basestring]), (self.__sk, [basestring]),
                      (debug, [bool]), (self.__args['src'], [basestring]),
                      (self.__host, [basestring])])
     checkParamsLimit([(image_source, ['0<=len(x)<=2048'])])
     if not self.__ak or not self.__sk or not self.__host:
         raise BaeConstructError("Invalid ak, sk, or image host")
     self.__requestId = 0
     self._debug = debug
     self.__strudata = None
コード例 #27
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setAnnotateOutputCode(self, output_code):
     checkParamsType([(output_code, [int])])
     checkParamsLimit([(output_code, ['0<=x<=4'])])
     self.__operations['desttype'] = output_code
コード例 #28
0
 def setQRCodeLevel(self, level):          
    checkParamsType([(level, [int])])
    checkParamsLimit([(level, ['1<=x<=4'])])
    self.__operations['level'] = level
コード例 #29
0
 def setAnnotateOutputCode(self, output_code):
    checkParamsType([(output_code, [int])])
    checkParamsLimit([(output_code, ['0<=x<=4'])])
    self.__operations['desttype'] = output_code
コード例 #30
0
 def setAnnotateQuality(self, quality):
    checkParamsType([(quality, [int])])
    checkParamsLimit([(quality, ['0<=x<=100'])])
    self.__operations['quality'] = quality
コード例 #31
0
 def setQRCodeMargin(self, margin):          
    checkParamsType([(margin, [int])])
    checkParamsLimit([(margin, ['1<=x<=100'])])
    self.__operations['margin'] = margin
コード例 #32
0
 def setQuality(self, quality = 60):
    checkParamsType([(quality, [int])])
    checkParamsLimit([(quality, ['0<=x<=100'])])
    self.__args['quality'] = quality
コード例 #33
0
 def setZooming(self, zooming_type, value, height_value = 0):
    checkParamsType([(zooming_type, [int]), (value, [int]), (height_value, [int])])
    checkParamsLimit([(zooming_type, ['1<=x<=4'])])
    if zooming_type == BaeImage.ZOOMING_TYPE_HEIGHT:
       checkParamsLimit([(value, ['0<=x<=10000'])])
       self.__args['size'] = 'b0_' + str(value)
    elif zooming_type == BaeImage.ZOOMING_TYPE_WIDTH:
       checkParamsLimit([(value, ['0<=x<=10000'])])
       self.__args['size'] = 'b' + str(value) + '_0'
    elif zooming_type == BaeImage.ZOOMING_TYPE_PIXELS:
       checkParamsLimit([(value, ['0<=x<=100000000'])])
       self.__args['size'] = 'p' + str(value)
    elif zooming_type == BaeImage.ZOOMING_TYPE_UNRATIO:
       checkParamsLimit([(value, ['0<=x<=10000'])]) 
       checkParamsLimit([(height_value, ['0<=x<=10000'])])
       self.__args['size'] = 'u' + str(value) + '_' + str(height_value)
コード例 #34
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setAnnotateQuality(self, quality):
     checkParamsType([(quality, [int])])
     checkParamsLimit([(quality, ['0<=x<=100'])])
     self.__operations['quality'] = quality
コード例 #35
0
 def setQRCodeSize(self, size):          
    checkParamsType([(size, [int])])
    checkParamsLimit([(size, ['0<x<=100'])])
    self.__operations['size'] = size
コード例 #36
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCompositeQuality(self, quality):
     checkParamsType([(quality, [int])])
     checkParamsLimit([(quality, ['0<=x<=100'])])
     self.__composite_quality = quality
コード例 #37
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setRotation(self, degree):
     checkParamsType([(degree, [int])])
     checkParamsLimit([(degree, ['0<=x<=360'])])
     self.__args['rotate'] = degree
コード例 #38
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setZooming(self, zooming_type, value, height_value=0):
     checkParamsType([(zooming_type, [int]), (value, [int]),
                      (height_value, [int])])
     checkParamsLimit([(zooming_type, ['1<=x<=4'])])
     if zooming_type == BaeImage.ZOOMING_TYPE_HEIGHT:
         checkParamsLimit([(value, ['0<=x<=10000'])])
         self.__args['size'] = 'b0_' + str(value)
     elif zooming_type == BaeImage.ZOOMING_TYPE_WIDTH:
         checkParamsLimit([(value, ['0<=x<=10000'])])
         self.__args['size'] = 'b' + str(value) + '_0'
     elif zooming_type == BaeImage.ZOOMING_TYPE_PIXELS:
         checkParamsLimit([(value, ['0<=x<=100000000'])])
         self.__args['size'] = 'p' + str(value)
     elif zooming_type == BaeImage.ZOOMING_TYPE_UNRATIO:
         checkParamsLimit([(value, ['0<=x<=10000'])])
         checkParamsLimit([(height_value, ['0<=x<=10000'])])
         self.__args['size'] = 'u' + str(value) + '_' + str(height_value)
コード例 #39
0
 def setHue(self, hue):
    checkParamsType([(hue, [int])])
    checkParamsLimit([(hue, ['1<=x<=100'])])
    self.__args['hue'] = hue
コード例 #40
0
 def setRotation(self, degree):
    checkParamsType([(degree, [int])])
    checkParamsLimit([(degree, ['0<=x<=360'])])
    self.__args['rotate'] = degree
コード例 #41
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setQRCodeSize(self, size):
     checkParamsType([(size, [int])])
     checkParamsLimit([(size, ['0<x<=100'])])
     self.__operations['size'] = size
コード例 #42
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setQRCodeMargin(self, margin):
     checkParamsType([(margin, [int])])
     checkParamsLimit([(margin, ['1<=x<=100'])])
     self.__operations['margin'] = margin
コード例 #43
0
 def setQRCodeVersion(self, version):          
    checkParamsType([(version, [int])])
    checkParamsLimit([(version, ['0<=x<=30'])])
    self.__operations['version'] = version
コード例 #44
0
 def setQRCodeText(self, text):
    checkParamsType([(text, [basestring])])
    if isinstance(text, unicode):
       text = text.encode('utf-8')
    checkParamsLimit([(text, ['1<=len(x)<=500'])])
    self.__source_data['data1'] = base64.b64encode(text) 
コード例 #45
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setCompositeOutputCode(self, output_code):
     checkParamsType([(output_code, [int])])
     checkParamsLimit([(output_code, ['0<=x<4'])])
     self.__composite_desttype = output_code
コード例 #46
0
 def setCompositeOpacity(self, opacity, img_key = 0):
    checkParamsType([(opacity, [int, float])])
    checkParamsLimit([(opacity, ['0.0<=x<=1.0'])])
    if img_key >= len(self.__strudata['req_data_source']):
       raise BaeValueError("invalid img_key, image %d isn't exist"%img_key)   
    self.__strudata['req_data_source'][img_key]['operations']['opacity'] = opacity
コード例 #47
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setQRCodeText(self, text):
     checkParamsType([(text, [basestring])])
     if isinstance(text, unicode):
         text = text.encode('utf-8')
     checkParamsLimit([(text, ['1<=len(x)<=500'])])
     self.__source_data['data1'] = base64.b64encode(text)
コード例 #48
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setSharpness(self, sharpness):
     checkParamsType([(sharpness, [int])])
     checkParamsLimit([(sharpness, ['1<=x<=200'])])
     self.__args['sharpen'] = sharpness
コード例 #49
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setQRCodeVersion(self, version):
     checkParamsType([(version, [int])])
     checkParamsLimit([(version, ['0<=x<=30'])])
     self.__operations['version'] = version
コード例 #50
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setSaturation(self, saturation):
     checkParamsType([(saturation, [int])])
     checkParamsLimit([(saturation, ['1<=x<=100'])])
     self.__args['saturation'] = saturation
コード例 #51
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setQRCodeLevel(self, level):
     checkParamsType([(level, [int])])
     checkParamsLimit([(level, ['1<=x<=4'])])
     self.__operations['level'] = level
コード例 #52
0
 def setCompositeOutputCode(self, output_code):
    checkParamsType([(output_code, [int])])
    checkParamsLimit([(output_code, ['0<=x<4'])])
    self.__composite_desttype = output_code
コード例 #53
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setQuality(self, quality=60):
     checkParamsType([(quality, [int])])
     checkParamsLimit([(quality, ['0<=x<=100'])])
     self.__args['quality'] = quality
コード例 #54
0
 def setCompositeQuality(self, quality):
    checkParamsType([(quality, [int])])
    checkParamsLimit([(quality, ['0<=x<=100'])])
    self.__composite_quality = quality
コード例 #55
0
 def setLightness(self, lightness):
    checkParamsType([(lightness, [int])])
    checkParamsLimit([(lightness, ['x>=1'])])
    self.__args['lightness'] = lightness
コード例 #56
0
 def setCompositeAnchor(self, anchor, img_key = 0):
    checkParamsType([(anchor, [int])])
    checkParamsLimit([(anchor, ['0<=x<=8'])])
    if img_key >= len(self.__strudata['req_data_source']):
       raise BaeValueError("invalid img_key, image %d isn't exist"%img_key)   
    self.__strudata['req_data_source'][img_key]['operations']['anchor_point'] = anchor
コード例 #57
0
 def setContrast(self, contrast):
    checkParamsType([(contrast, [int])])
    checkParamsLimit([(contrast, ['0<=x<=1'])])
    self.__args['contrast'] = contrast
コード例 #58
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setContrast(self, contrast):
     checkParamsType([(contrast, [int])])
     checkParamsLimit([(contrast, ['0<=x<=1'])])
     self.__args['contrast'] = contrast
コード例 #59
0
ファイル: image.py プロジェクト: marsfeng/bae-python-sdk
 def setHue(self, hue):
     checkParamsType([(hue, [int])])
     checkParamsLimit([(hue, ['1<=x<=100'])])
     self.__args['hue'] = hue
コード例 #60
0
 def setSaturation(self, saturation):
    checkParamsType([(saturation, [int])])
    checkParamsLimit([(saturation, ['1<=x<=100'])])
    self.__args['saturation'] = saturation