@click.command()
@click.option('--amount', '-a', type=click.IntRange(0, 99, clamp=True),
              default=random.randint(0, 99), help="Insert high or low values?")
@click.option('--seed', '-s', type=click.IntRange(0, 99, clamp=True),
              default=random.randint(0, 99), help="Begin glitching at the\
                      start on a bit later on.")
@click.option('--iterations', '-i', type=click.IntRange(0, 115, clamp=True),
              default=random.randint(0, 115), help="How many values should\
                      get replaced.")
@click.option('--jpg', is_flag=True, help="Output to jpg instead of png.\
                      Note that png is more stable")
@click.option('--output', '-o', help="What to call your glitched file.")
@click.argument('image', type=click.File('rb'))
def cli(image, amount, seed, iterations, jpg, output):
    image_bytes = bytearray(image.read())
    jpeg = Jpeg(image_bytes, amount, seed, iterations)

    click.echo("\nScrambling your image with the following parameters:")
    for key, value in jpeg.parameters.iteritems():
        click.echo(message=key + ': ' + str(value))

    if output:
        # TODO
        # make the extension here count as guide for what to save the file as
        # for now just ignore it if it's given
        name = output.rsplit('.')[0]
    else:
        name = image.name.rsplit('.')[0] + "_glitched"

    name += '%s' % ('.jpg' if jpg else '.png')

    jpeg.save_image(name)

    output = "\nSucces! Checkout %s." % name
    click.echo(output)
dataset/ETHPy150Open Kareeeeem/jpglitch/jpglitch.py/cli/original