[Python] Can't save images using python ImageEnhance module

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am a new python programmer and I am trying to use the ImageEnhance module to create a set of images that increase sharpness over time.

    The script below works with one problem: the new images are being save to a temporary directory that quickly deletes the files.

    How do I alter the save function to point to a proper directory.

    Thanks in advance.

    #import modules
    import sys
    import os
    import Image, ImageEnhance,

    #find directory, load picture
    os.chdir ("/Users/ericmaie/Desktop/test")
    backup_directory = "/Users/harddrive/Desktop/test2"

    counter = 1

    while (counter < 5):

    ima = Image.open("1.png")
    enhancer = ImageEnhance.Sharpness(ima)
    factor = (counter + 10) / 4.0
    enhancer.enhance(factor).show("Sharpness %f" % factor)
    ima.save(str(counter) + '.jpg')

    counter = counter + 1

    Continue reading...

Compartilhe esta Página