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


Python OpenImageIO.geterror方法代码示例

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


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

示例1: poor_mans_iinfo

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def poor_mans_iinfo (filename) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    sub = 0
    mip = 0
    while True :
        if sub > 0 or mip > 0 :
            print "Subimage", sub, "MIP level", mip, ":"
        print_imagespec (input.spec(), mip=mip)
        mip = mip + 1
        if input.seek_subimage (sub, mip) :
            continue    # proceed to next MIP level
        else :
            sub = sub + 1
            mip = 0
            if input.seek_subimage (sub, mip) :
                continue    # proceed to next subimage
        break  # no more MIP levels or subimages
    input.close ()
    print
开发者ID:Chifoncake,项目名称:oiio,代码行数:27,代码来源:test_imageinput.py

示例2: test_readtile

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def test_readtile (filename, sub=0, mip=0, type=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if spec.tile_width == 0 :
        print "Error: not tiled"
        return
    if type == oiio.UNKNOWN :
        type = spec.format.basetype
    # Randomly read a couple of tiles, print a pixel from within it
    (tx,ty) = (spec.x, spec.y)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    if data == None :
        print "read returned None"
        return
    (x,y) = (tx+spec.tile_width/2, ty+spec.tile_height/2)
    i = ((y-ty)*spec.tile_width + (x-tx)) * spec.nchannels
    print "@", (x,y), "=", data[i:i+spec.nchannels]
    (tx,ty) = (spec.x+2*spec.tile_width, spec.y+2*spec.tile_height)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    (x,y) = (tx+spec.tile_width/2, ty+spec.tile_height/2)
    i = ((y-ty)*spec.tile_width + (x-tx)) * spec.nchannels
    print "@", (x,y), "=", data[i:i+spec.nchannels]
    input.close ()
    print
开发者ID:Chifoncake,项目名称:oiio,代码行数:33,代码来源:test_imageinput.py

示例3: test_readscanline

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def test_readscanline (filename, sub=0, mip=0, type=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if spec.tile_width != 0 :
        print "Error: tiled"
        return
    if type == oiio.UNKNOWN :
        type = spec.format.basetype
    for y in range(spec.height) :
        data = input.read_scanline (y+spec.y, spec.z, type)
        if data == None :
            print "read returned None"
            return
        # print the first pixel of the first and last scanline
        if y == 0 or y == (spec.height-1) :
            i = 0 * spec.nchannels
            print "@", (spec.x,y+spec.y), "=", data[i:i+spec.nchannels]
    input.close ()
    print
开发者ID:Chifoncake,项目名称:oiio,代码行数:28,代码来源:test_imageinput.py

示例4: test_readtile

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def test_readtile (filename, sub=0, mip=0, type=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print ('Could not open "' + filename + '"')
        print ("\tError: ", oiio.geterror())
        print ()
        return
    print ('Opened "' + filename + '" as a ' + input.format_name())
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if spec.tile_width == 0 :
        print ("Error: not tiled")
        return
    if type == oiio.UNKNOWN :
        type = spec.format.basetype
    # Randomly read a couple of tiles, print a pixel from within it
    (tx,ty) = (spec.x, spec.y)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    if data is None :
        print ("read returned None")
        return
    (x,y) = (tx+spec.tile_width//2, ty+spec.tile_height//2)
    print ("@", (x,y), "=", data[y,x])
    (tx,ty) = (spec.x+2*spec.tile_width, spec.y+2*spec.tile_height)
    data = input.read_tile (tx+spec.x, ty+spec.y, spec.z, type)
    print ("@", (x,y), "=", data[y,x])
    input.close ()
    print ()
开发者ID:AtomicFiction,项目名称:oiio,代码行数:30,代码来源:test_imageinput.py

示例5: test_readimage

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def test_readimage (filename, sub=0, mip=0, type=oiio.UNKNOWN,
                    method="image", nchannels=0,
                    print_pixels = True, keep_unknown=False) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print ('Could not open "' + filename + '"')
        print ("\tError: ", oiio.geterror())
        print ()
        return
    print ('Opened "' + filename + '" as a ' + input.format_name())
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if nchannels == 0 or method == "image" :
        nchannels = spec.nchannels
    if str(type) == "unknown" and not keep_unknown :
        type = spec.format.basetype
    if method == "image" :
        data = input.read_image (type)
    elif method == "scanlines" :
        data = input.read_scanlines (spec.y, spec.y+spec.height, spec.z,
                                     0, nchannels, type)
    elif method == "tiles" :
        data = input.read_tiles (spec.x, spec.x+spec.width,
                                 spec.y, spec.y+spec.height,
                                 spec.z, spec.z+spec.depth,
                                 0, nchannels, type)
    else :
        print ("Unknown method:", method)
        return
    if data is None :
        print ("read returned None")
        return
    if print_pixels :
        # print the first, last, and middle pixel values
        (x,y) = (spec.x, spec.y)
        print ("@", (x,y), "=", data[y,x])
        (x,y) = (spec.x+spec.width-1, spec.y+spec.height-1)
        print ("@", (x,y), "=", data[y,x])
        (x,y) = (spec.x+spec.width//2, spec.y+spec.height//2)
        print ("@", (x,y), "=", data[y,x])
    else :
        print ("Read array typecode", data.dtype, " [", data.size, "]")
    # Test the spec and spec_dimensions methods
    spec = input.spec_dimensions (0, 0)
    if len(spec.extra_attribs) > 0 :
        print ("wrong spec_dimensions(s,m) metadata items: ", len(spec.extra_attribs))
    spec = input.spec (0, 0)
    if len(spec.extra_attribs) == 0 :
        print ("wrong spec(s,m) metadata items: ", len(spec.extra_attribs))
    input.close ()
    print ()
开发者ID:AtomicFiction,项目名称:oiio,代码行数:53,代码来源:test_imageinput.py

示例6: test_readimage

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def test_readimage (filename, sub=0, mip=0, type=oiio.UNKNOWN,
                    method="image", nchannels=0,
                    print_pixels = True, keep_unknown=False) :
    input = oiio.ImageInput.open (filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    print 'Opened "' + filename + '" as a ' + input.format_name()
    input.seek_subimage (sub, mip)
    spec = input.spec ()
    if nchannels == 0 or method == "image" :
        nchannels = spec.nchannels
    if type == oiio.UNKNOWN and not keep_unknown :
        type = spec.format.basetype
    if method == "image" :
        data = input.read_image (type)
    elif method == "scanlines" :
        data = input.read_scanlines (spec.y, spec.y+spec.height, spec.z,
                                     0, nchannels, type)
    elif method == "tiles" :
        data = input.read_tiles (spec.x, spec.x+spec.width,
                                 spec.y, spec.y+spec.height,
                                 spec.z, spec.z+spec.depth,
                                 0, nchannels, type)
    else :
        print "Unknown method:", method
        return
    if data == None :
        print "read returned None"
        return
    if print_pixels :
        # print the first, last, and middle pixel values
        (x,y) = (spec.x, spec.y)
        i = ((y-spec.y)*spec.width + (x-spec.x)) * nchannels
        print "@", (x,y), "=", data[i:i+nchannels]
        (x,y) = (spec.x+spec.width-1, spec.y+spec.height-1)
        i = ((y-spec.y)*spec.width + (x-spec.x)) * nchannels
        print "@", (x,y), "=", data[i:i+nchannels]
        (x,y) = (spec.x+spec.width/2, spec.y+spec.height/2)
        i = ((y-spec.y)*spec.width + (x-spec.x)) * nchannels
        print "@", (x,y), "=", data[i:i+nchannels]
    else :
        print "Read array typecode", data.typecode, " [", len(data), "]"
    input.close ()
    print
开发者ID:ElaraFX,项目名称:oiio,代码行数:49,代码来源:test_imageinput.py

示例7: copy_image

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def copy_image (in_filename, out_filename, method="image") :
    input = oiio.ImageInput.open (in_filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    spec = input.spec ()
    output = oiio.ImageOutput.create (out_filename)
    if not output :
        print "Could not create ImageOutput for", out_filename
        return
    ok = output.open (out_filename, spec, oiio.Create)
    if not ok :
        print "Could not open", out_filename
        return
    ok = copy_subimage (input, output, method)
    input.close ()
    output.close ()
    if ok :
        print "Copied", in_filename, "to", out_filename, "as", method
开发者ID:Chifoncake,项目名称:oiio,代码行数:23,代码来源:test_imageoutput.py

示例8: copy_image

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def copy_image (in_filename, out_filename, method="image",
                memformat=oiio.TypeFloat, outformat=oiio.TypeUnknown) :
    input = oiio.ImageInput.open (in_filename)
    if not input :
        print ('Could not open "' + filename + '"')
        print ("\tError: ", oiio.geterror())
        print ()
        return
    outspec = input.spec()
    if outformat != oiio.TypeUnknown :
        outspec.format = outformat
    output = oiio.ImageOutput.create (out_filename)
    if not output :
        print ("Could not create ImageOutput for", out_filename)
        return
    ok = output.open (out_filename, outspec)
    if not ok :
        print ("Could not open", out_filename)
        return
    ok = copy_subimage (input, output, method, memformat)
    input.close ()
    output.close ()
    if ok :
        print ("Copied", in_filename, "to", out_filename, "as", method)
开发者ID:StereoD-Development,项目名称:oiio,代码行数:26,代码来源:test_imageoutput.py

示例9: copy_image

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
def copy_image (in_filename, out_filename, method="image",
                memformat=oiio.FLOAT, outformat=oiio.UNKNOWN) :
    input = oiio.ImageInput.open (in_filename)
    if not input :
        print 'Could not open "' + filename + '"'
        print "\tError: ", oiio.geterror()
        print
        return
    outspec = input.spec ()
    if (outformat != oiio.UNKNOWN) :
        outspec.format = oiio.TypeDesc(outformat)
    output = oiio.ImageOutput.create (out_filename)
    if not output :
        print "Could not create ImageOutput for", out_filename
        return
    ok = output.open (out_filename, outspec, oiio.Create)
    if not ok :
        print "Could not open", out_filename
        return
    ok = copy_subimage (input, output, method, memformat)
    input.close ()
    output.close ()
    if ok :
        print "Copied", in_filename, "to", out_filename, "as", method
开发者ID:ElaraFX,项目名称:oiio,代码行数:26,代码来源:test_imageoutput.py

示例10: print

# 需要导入模块: import OpenImageIO [as 别名]
# 或者: from OpenImageIO import geterror [as 别名]
#######################################################
# Create an exr file with deliberately missing tiles

tilesize = 64
res = 256
tile = np.ones((tilesize,tilesize,3), dtype='float') * 0.75

spec = oiio.ImageSpec(res, res, 3, "half")
spec.tile_width = tilesize
spec.tile_height = tilesize
spec.attribute('openexr:lineOrder', 'randomY')

out = oiio.ImageOutput.create ('partial.exr')
if not out :
    print ('Could not create ImageOutput: ', oiio.geterror())
ok = out.open ('partial.exr', spec)
if not ok :
    print ('Could not open file: ', out.geterror())
count = 0
for y in range(0,res,tilesize) :
    for x in range(0,res,tilesize) :
        # Skip every 7th tile
        if (count % 7) > 1 :
            ok = out.write_tile (x, y, 0, tile)
            if not ok :
                print ('Could not write tile y={} x={}: {}'.format(y, x, out.geterror()))
        count += 1

out.close()
开发者ID:AtomicFiction,项目名称:oiio,代码行数:31,代码来源:makepartialexr.py


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