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


Python Image.profile方法代码示例

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


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

示例1: resize3

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize3( srcFile="", destFile="", w=200,h=200, color="", crop=False, align="center" ):

        img = Image(srcFile)
        img.scale("%dx%d>"%(w,h))
        img.profile("*",Blob())
        img.write(destFile)
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:9,代码来源:myGraphicsMagick.py

示例2: resize2

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
 def resize2( srcFile="", destFile="", w=200,h=200 ):
     blobData = Blob(open(srcFile).read())
     if ( h != -1 ):
         img = Image( blobData, Geometry(w, h))
         img.scale("%dx%d!" % (w,h))
     else:
         img = Image( blobData )
         img.scale("%dx!" % w )
     img.profile("*",Blob())
     img.write(destFile)
     return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:13,代码来源:myGraphicsMagick.py

示例3: resize0

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize0( srcFile="", destFile="", w=200 ):

        img = Image(srcFile)
        sw = img.columns()
        sh = img.rows()
        if ( sw > w  ):
            tw = w
            th = sh*(float(w)/float(sw))
            img.scale("%dx%d"%(tw,th))
        img.profile("*", Blob())
        img.write(destFile)
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:14,代码来源:myGraphicsMagick.py

示例4: resize10

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize10( srcFile="", destFile="", w=200 ):
        img = Image( srcFile )
        sw = img.columns()
        sh = img.rows()
        scale = sw*sh

        if ( scale > w ):
            tw = int(sw*((float(w)/float(scale))**0.5))
            th = int(w/tw)
            img.scale("%dx%d"%(tw,th))
        img.profile("*",Blob())
        img.write(destFile)
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:15,代码来源:myGraphicsMagick.py

示例5: convert_split

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def convert_split(srcfile='', dstpath='', truefile='', split='3x3', w=100, h=100):
        """
        目前仅用作封面频道
        """
        srcfile = srcfile.encode("utf-8")
        dstpath = dstpath.encode("utf-8")
        truefile = truefile.encode("utf-8")
        (sp_x, sp_y) = split.split('x')
        (file_name, image_ext) = os.path.splitext(os.path.basename(srcfile))

        cw = int(sp_x) * int(w)
        ch = int(sp_y) * int(h)
        t1 = time.time()
        #生成封面列表图
        re = myGraphicsMagick.convert_gif_thumbnail_frame0_g(srcfile=srcfile, dstfile=truefile, w=cw, h=ch,
            need_return=False)


        if re == True:
            #切割方式为从图片的左上开始逐行切割
            #目标图片文件名为:50d8059b1a822.11.jpg
            blobData = Blob(open(srcfile).read())

            try:
                num = 0#图片输出的编号
                for j in range(int(sp_y)):

                    if ( num >= ( int( sp_x )*int( sp_y ) - 1 ) ):
                        break
                    for i in range(int(sp_x)):
                        img = Image( blobData, Geometry(cw,ch) )
                        linePos = i * int(w)
                        colsPos = j * int(h)
                        #从指定的像素点进行裁剪
                        img.crop( Geometry(w,h,linePos, colsPos) )
                        destFilename = dstpath+'/%s.%d.%s' %( file_name,num,image_ext )
                        img.profile("*",Blob())
                        img.write( destFilename )
                        num = num + 1
                t2 = time.time()
                sys.stdout.writelines(datetime.now().strftime('%Y-%m-%d %H:%M:%S  ')+"libconvert appName:%s ver:%s cmdSN:%s type:%s cmdData:%s command : convert_split srcfile:%s dstfile:%s runTime:%s\n" % ( proto.protocal['appName'],proto.protocal['ver'],proto.protocal['cmdSN'],proto.protocal['type'],proto.protocal['cmdData'], srcfile,dstfile,(t2-t1)) )
                sys.stdout.flush()
                return ret
            except Exception as e:
                sys.stderr.writelines(datetime.now().strftime('%Y-%m-%d %H:%M:%S  ')+"libconvert_split %s %s srcfile:%s destFilename:%s\n" % (e.args, e.message, srcfile,destFilename))
                sys.stderr.flush()
                return 'False'
        else:
            return "False"
            pass
        return 'True'
开发者ID:sqj0213,项目名称:photoEncode,代码行数:53,代码来源:myGraphicsMagick.py

示例6: resize8

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize8( srcFile="", destFile="", w=200,h=200 ):
        img = Image(srcFile)

        #.def("extent", (void (Magick::Image::*)(const Magick::Geometry&, const Magick::Color&, const Magick::GravityType))&Magick::Image::extent)
        #白色背景图
        backImg = None

        #sw源图宽度
        sw = img.columns()
        #sh源图高度
        sh = img.rows()
        #若目标图的宽或高都比源图大则不处理
        if ( sw <= w and sh <= h ):
            backImg = Image(Geometry(w,h), 'white' )
            backImg.composite(img, GravityType.CenterGravity, co.OverCompositeOp)
            backImg.profile("*",Blob())
            backImg.write(destFile)
            return "True"
        #目标的宽或高都比源图的小则进行裁剪
        elif ( sw > w and sh > h ):
            #源图的宽高比
            sratio = float(sw)/float(sh)
            rratio = float(w)/float(h)
            #若源图宽高比大于目标图的宽高比的话,则就高缩放,从0,0位置裁前源图宽
            #print sratio,rratio
            if ( sratio > rratio ):
                hscale = float(h)/float(sh)
                rw = int(sw*hscale)
                rh = int(sh*hscale)
            else:
                wscale = float(w)/float(sw)
                rw = int(sw*wscale)
                rh = int(sh*wscale)

            linePos = int( (rw-w)/2)
            colPos = int( (rh-h)/2)

            img.scale("%dx%d"%(rw,rh))
            img.crop(Geometry(w,h,linePos,colPos))
            img.profile("*",Blob())
            img.write(destFile)
            return "True"
        elif ( sw > w ):
            backImg = Image(Geometry(w,h), 'white' )
            img.crop(Geometry(w,sh,int((sw-w)/2)))
            backImg.composite(img,GravityType.CenterGravity,co.OverCompositeOp )
            backImg.profile("*",Blob())
            backImg.write(destFile)
            return "True"
        elif ( sh > h ):
            backImg = Image(Geometry(w,h), 'white' )
            img.crop( Geometry(sw,h,0,int((sh-h)/2) ) )
            backImg.composite(img, GravityType.CenterGravity,co.OverCompositeOp )
            backImg.profile("*",Blob())
            backImg.write(destFile)
            return "True"
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:59,代码来源:myGraphicsMagick.py

示例7: resize9

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize9( srcFile="", destFile="", w=200,h=200, color="", crop=False, align="center" ):
        img = Image(srcFile)

        #白色背景图
        backImg = None

        #sw源图宽度
        sw = img.columns()
        #sh源图高度
        sh = img.rows()

        #目标图与源图的宽比例
        wScale = float(w)/float(sw)
        #目标图与源图的高比例
        hScale = float(h)/float(sh)

        if ( w > sw or h > sh ):
            if (wScale == hScale ):
                tw = w
                th = h
            elif ( wScale < hScale ):
                th = h
                tw = sw*wScale
            else:
                tw = w
                th = sh*hScale
        elif( w<sw or h < sh ):
            if (wScale == hScale ):
                tw = w
                th = h
            elif ( wScale < hScale ):
                th = h
                tw = sw*wScale
            else:
                tw = w
                th = sh*hScale
        else:
            tw = sw
            th = sh
        img.scale("%dx%d"%(tw,th))
        backImg = Image(Geometry(w,h), 'white' )
        backImg.composite(img,GravityType.CenterGravity,co.OverCompositeOp )
        backImg.profile("*",Blob())
        backImg.write(destFile)
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:47,代码来源:myGraphicsMagick.py

示例8: resize1

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize1( srcFile="", destFile="", w=200,h=200 ):
        img = Image( srcFile )
        #sw源图宽度
        sw = img.columns()
        sh = img.rows()
        #要缩略的宽度
        rw = w
        #要缩略的高度
        rh = h

        #源图的宽高比
        sratio = float(sw)/float(sh)
        #目标图的宽高比
        rratio = float(rw)/float(rh)

        #若源图的宽高比大于目标图的宽高比时,则按照高进行缩放后再裁剪宽度
        if ( sratio > rratio ):
            hscale = float(rh)/float(sh)
            w = sw*hscale
            h = sh*hscale
            #print (sw,sh,w,h,rw,rh,hscale)
            #就高缩放
            img.scale("%dx%d"%(w,h))
            #计算裁剪宽的部分的横坐标,超出的宽的部分进行裁剪
            tmpRowsPos = int((sw*hscale - rw)/2)
            img.crop(Geometry( rw,rh,tmpRowsPos,0 ) )
        #若源图的宽高比小于目标图的宽高比时,则按照宽进行缩放后再裁剪高度
        else:
            wscale = float(rw)/float(sw)

            w = sw*wscale
            h = sh*wscale
            #print (sw,sh,w,h,rw,rh,wscale)
            #就宽缩放
            img.scale("%dx%d"%(w,h))
            tmpColsPos = int((sh*wscale-rh)/2 )
            img.crop( Geometry( rw,rh,0,tmpColsPos )  )
            #只有宽大于目标宽度的时候才进行缩略
        #elif ( sw > w ):
        #    pass
        #unicodestring.encode("utf-8")
        img.profile("*", Blob())
        img.write(destFile)
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:46,代码来源:myGraphicsMagick.py

示例9: resize7

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize7( srcFile="", destFile="", w=200,h=200 ):
        img = Image(srcFile)

        #白色背景图
        backImg = None

        #sw源图宽度
        sw = img.columns()
        #sh源图高度
        sh = img.rows()
        #若目标图的宽或高都比源图大则不处理
        if ( sw <= w and sh <= h ):
            backImg = Image(Geometry(w,h), 'white' )
            backImg.composite(img, Geometry( sw, sh, 0, 0 ), co.OverCompositeOp)
            backImg.profile("*",Blob())
            backImg.write(destFile)
            return "True"
        #目标的宽或高都比源图的小则进行裁剪
        elif ( sw > w and sh > h ):
            #源图的宽高比
            sratio = float(sw)/float(sh)
            rratio = float(w)/float(h)
            #若源图宽高比大于目标图的宽高比的话,则就高缩放,从0,0位置裁前源图宽
            #print sratio,rratio
            if ( sratio > rratio ):
                hscale = float(h)/float(sh)
                rw = int(sw*hscale)
                rh = int(sh*hscale)
            else:
                wscale = float(w)/float(sw)
                rw = int(sw*wscale)
                rh = int(sh*wscale)
            img.scale("%dx%d"%(rw,rh))
            img.crop(Geometry(w,h,0,0))
            img.profile("*",Blob())
            img.write(destFile)
            return "True"
        elif ( sw > w ):
            backImg = Image(Geometry(w,h), 'white' )
            img.crop(Geometry(w,sh))
            backImg.composite(img,Geometry(w,h,0,0),co.OverCompositeOp )
            backImg.profile("*",Blob())
            backImg.write(destFile)
            return "True"
        elif ( sh > h ):
            backImg = Image(Geometry(w,h), 'white' )
            img.crop( Geometry(sw,h) )
            backImg.composite(img, Geometry(w,h,0,0),co.OverCompositeOp )
            backImg.profile("*",Blob())
            backImg.write(destFile)
            return "True"
        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:54,代码来源:myGraphicsMagick.py

示例10: resize5

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
    def resize5( srcFile="", destFile="", w=200,h=200 ):

        #CONVERT_RESIZE_CROP = "%s -resize %d" + "x" + " -crop %d" + "x" + "%d" + "+0+0 +repage %s"
        img = Image( srcFile )
        sw = img.columns()
        sh = img.rows()

        #源图宽高比
        sratio = float(sw)/float(sh)
        #目标图宽高比
        tratio = float(w)/float(h)

        #若源图的宽高比大于目标图的宽高比,则
        if( sratio == tratio and (w==sw) and (h==sh )):
            img.profile("*",Blob())
            img.write(destFile)
            return "True"
        elif ( sratio > tratio ):
            hscale = float(w)/float(sw)
            tw = sw*hscale
            th = sh*hscale
            img.scale("%dx"%(tw))
            if ( th > h ):
                img.crop(Geometry(w,h))
            img.profile("*",Blob())
            img.write(destFile)
            return "True"
        elif( sratio < tratio ):
            wscale = float(w)/float(sw)

            tw = int(sw*wscale)
            th = int(sh*wscale)
            #260 132 670 502 0.388059701493 260 194

            img.scale("%dx%d"%(tw,th))
            if ( th > h ):
                img.crop(Geometry(w,h))
            img.profile("*",Blob())
            img.write(destFile)
            return "True"

        return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:44,代码来源:myGraphicsMagick.py

示例11: rotate

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
 def rotate(srcFile="", destFile="", rotate=90):
     img =Image( srcFile )
     img.rotate( int(rotate) )
     img.profile("*",Blob())
     img.write( destFile )
     return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:8,代码来源:myGraphicsMagick.py

示例12: resize4

# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import profile [as 别名]
 def resize4( srcFile="", destFile="", w=200,h=200 ):
     img = Image(srcFile)
     img.scale("%dx%d<"%(w,h))
     img.profile("*",Blob())
     img.write(destFile)
     return "True"
开发者ID:sqj0213,项目名称:photoEncode,代码行数:8,代码来源:myGraphicsMagick.py


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