def main(imgfile, percentages):
    with TimerContext("# " + imgfile, "Loading"):
        im = VImage.VImage(imgfile, "r")

    for pc in percentages:
        if pc <= 0 or pc > 100:
            print "Illegal percentage: ", pc
            exit(1)

        outfile = "%d-vips-py-%s" % (pc, imgfile)
        sz = round(100.0/pc)
        with TimerContext(imgfile, str(pc)):
            im.shrink(sz, sz).write(outfile)

    printResults()
Exemple #2
0
def main(imgfile, percentages):
    with TimerContext("# " + imgfile, "Loading"):
        im = VImage.VImage(imgfile, "r")

    for pc in percentages:
        if pc <= 0 or pc > 100:
            print "Illegal percentage: ", pc
            exit(1)

        outfile = "%d-vips-py-%s" % (pc, imgfile)
        sz = round(100.0 / pc)
        with TimerContext(imgfile, str(pc)):
            im.shrink(sz, sz).write(outfile)

    printResults()
def main(imgfile, widths):
    with TimerContext("# " + imgfile, "Loading"):
        im = Image.open(imgfile)

    iw, ih = im.size

    count = 1
    for width in widths:
        if width <= 0:
            print "Illegal width: ", width
            exit(1)

        height = int(round( float(ih * width) / iw))

        outfile = "%d-pil-%d-%s" % (width, count, os.path.basename(imgfile))
        count = count + 1

        with TimerContext(imgfile, str(width)):
            result = im.resize( (width, height), Image.BICUBIC)

        with TimerContext(outfile, "saving..."):
            result.save(outfile, "JPEG")

    printResults()
def main(imgfile, widths):
    with TimerContext("# " + imgfile, "Loading"):
        im = Image.open(imgfile)

    iw, ih = im.size

    count = 1
    for width in widths:
        if width <= 0:
            print "Illegal width: ", width
            exit(1)

        height = int(round(float(ih * width) / iw))

        outfile = "%d-pil-%d-%s" % (width, count, os.path.basename(imgfile))
        count = count + 1

        with TimerContext(imgfile, str(width)):
            result = im.resize((width, height), Image.BICUBIC)

        with TimerContext(outfile, "saving..."):
            result.save(outfile, "JPEG")

    printResults()