+-+-+-+-+-+-+
|B|R|U|I|S|E|
+-+-+-+-+-+-+
home | categories | readme

viewer

I read this essay by Jon Uriate, Delete by Default. Possibly because I'm procrastinating working on other things I was wondering about a user-side tool to implement something along the lines of data erasure or entropy that Uriate points to.

I enjoy thinking about creative responses to these kind of things, which are almost certainly impractical to scale, but could perhaps still be useful in places like this website, or within other experimental contexts.

Similar to my thinking about webcams I don't really have the knowledge to build something that works like an app, but I can smush together a few python commands and outline a file structure that makes something happen.

I've proposed a system here that will reduce the size of an image by 25% each time it is opened. Using the system, the metadata of the image wouldn't be lost, but the size would reduce until it reached a 1x1 pixel.

Directory


├── gulp.py
├── images
│   ├── image.png
└── log.txt

Gulp.py


    import os
    from pathlib import Path
    from wand.image import Image
    
    # if not reduce
    def resizer():
        print("Making smaller")
        bye = Image(filename ='images/image.png')
        print (bye.width)
        new_width = round((bye.width)*0.75)
        new_height = round((bye.height)*0.75)
        print (new_width)
        bye.resize(round(new_width), round(new_height))
        bye.save(filename=r"images/image.png")
        # os.remove(r"images/image.png")
        bye.close()
    
     
    filepath = r"images/image.png"
    
    last_access_time = os.path.getatime(filepath)
    # print('File Last access time is: {}'.format(datetime.datetime.fromtimestamp(last_access_time)))
    
    print(str(last_access_time))
    
    # open log
    log_access_time = Path('log.txt').read_text()
    
    # compare if log is the same as access
    if (str(last_access_time)) == log_access_time:
        print('already matched')   
    else:
        print('updating')
        print(str(log_access_time))
        log_access_update = open("log.txt", "w")
        log_access_update.write(str(last_access_time))
        log_access_update.close()
        resizer()

This works with a single defined image. If I have a chance I might try to set it up so that it works with a folder of images automatically (although I always like intentionality and manual moements in code anyway).

It would be set to run as a cron job. I don't think I'd be opening images too often, so I'd maybe set it to run once a month.


categories: code


~gg 02/23

+-+-+-+-+-+-+
|B|R|U|I|S|E|
+-+-+-+-+-+-+