GlitchKnight & Python
GlitchKnight GlitchKnight
Got any code that turns a static image into a glitch? I’ve been tinkering with Perlin noise to push pixels into a nostalgic, pixel‑burst wave—thought you might dig the math behind the distortion.
Python Python
import random from PIL import Image, ImageChops, ImageEnhance import numpy as np def glitch_image(path, out_path, shift_max=15, bright_factor=1.3): img = Image.open(path).convert("RGB") arr = np.array(img) w, h = img.size # random vertical slice shifts for _ in range(random.randint(3, 7)): y = random.randint(0, h - 1) shift = random.randint(-shift_max, shift_max) if shift == 0: continue if shift > 0: arr[y: , :] = np.roll(arr[y: , :], shift, axis=1) else: arr[y: , :] = np.roll(arr[y: , :], shift, axis=1) # color channel misalignment r, g, b = arr[:,:,0], arr[:,:,1], arr[:,:,2] r = np.roll(r, random.randint(-shift_max, shift_max), axis=0) g = np.roll(g, random.randint(-shift_max, shift_max), axis=1) b = np.roll(b, random.randint(-shift_max, shift_max), axis=0) glitched = np.stack([r,g,b], axis=2) # brighten a little glitched = np.clip(glitched * bright_factor, 0, 255).astype(np.uint8) Image.fromarray(glitched).save(out_path) # usage # glitch_image('input.png', 'glitch.png')
GlitchKnight GlitchKnight
Nice loop of random shifts, feels like a digital pulse. You could swap the roll axis for the blue channel so the misalignment feels even more fractured—like a glitch bleeding through color space. Also try mixing in a little static by adding random pixel noise after the brighten step; that gives the final print a bit of that nostalgic, grainy feel. Remember, the more chaotic you make it, the more it speaks to the digital soul.
Python Python
That’s a neat tweak – swap the roll on the blue channel to let it drift differently, and then sprinkle a tiny amount of salt‑and‑pepper noise after you brighten. It’ll give the whole thing that classic VHS‑like grain. Just a quick snippet to patch it up: ```python # after brightening noise = np.random.randint(0, 30, glitched.shape, dtype=np.uint8) glitched = np.clip(glitched + noise, 0, 255) ``` Give it a spin and let the chaos do its thing.
GlitchKnight GlitchKnight
Yeah, that noise layer will make the glitch look like a corrupted feed rather than just a clean distortion. Maybe add a small Gaussian blur afterwards to soften the grain—keeps it from looking too raw, but still keeps that VHS vibe. Happy hacking.