maff

welcome to my web page

last.fm listening

 


 

i am just a litel babie……

 


 

how do i centre these dang images
unci fonts now!
maff.scot


my telegram channel where i post the absolute worst shit you've ever seen
badposts.t.me/

maff
@maff

how did i do this? why did i do this? click read more if you want. i promise it won't torture your browser.


it was very difficult getting this working on cohost because they sensibly have a limit to how large the request body of a post can be, and that limit is two hundred kill of bytes (roughly)

the idea came to me while i was talking to @konsti and i just went

Maff Today

hey konsti i just had the worst fucking idea in the world

write a script that takes an image input and converts each pixel into a 1px by 1px div with a bounce animation and randomised timing

for cohost

Konsti, tiny doggie Today

, oh no

maff that would

that would curse the living daylight out of everything dsfjklsda

Maff Today

I Am Going To Do It

Konsti, tiny doggie Today

please but also Ur Cursed

so with this exchange i began working on my crime. i opened up jetbrains datalore because i have it free from my work and i don't want to fuck about with python install

Maff half an hour later

hmm i have invented the Heavy Bitmap

turns out when you take an image and scale it (proportionally) to 400x400 and then generate html for every single one of the pixels it has, that generates a roughly 8mb file. i think that's more than the 200kb limit so i had to scale more. in the end i came up with the following code:

cohost crime dot py

from PIL import Image
from random import random
outl = []
px = 0
py = 0
scalefactor=4
scaleto=(31,31)
with Image.open("7.png") as pim:
    pim.thumbnail(scaleto)
    px = pim.width
    py = pim.height
    for y in range(0,pim.height):
        for x in range(0,pim.width):
            (r,g,b) = pim.getpixel((x,y))
            clr = ""
            if x == pim.width:
                clr = 'clear:right;'
            outl.append(f"<div style=\"height:{scalefactor}px;width:{scalefactor}px;float:left;display:inline-block;animation: {random()+random()}s ease {random()}s infinite normal none running bounce;background-color:rgb({r},{g},{b});{clr}\"></div>")
with open("out.txt", 'w') as fh:
    fh.write(f"<div style=\"height:{py*scalefactor}px;width:{px*scalefactor}px;\">\n")
    fh.write("\n".join(outl))
    fh.write("</div>")
print(f"num pixels: {len(outl)}, strsize: {len(' '.join(outl))}")

scaling the image proportionally to 31x31 and then upscaling each pixel to 4x4 results in something vaguely comprehensible and the bounce animation turned out to be much less cursed than expected, but it sure is torturous on the browser !!!


You must log in to comment.

in reply to @maff's post: