>>107759231
ComfyUI, Z image turbo, hard pixel lora, and finishing touches with a simple python script that was generated by Gemini:
import os
import imagequant
from PIL import Image, ImageEnhance
def make_blocky_pixel(input_path, output_path, pixel_size=2):
# 1. Load Image
img = Image.open(input_path).convert("RGB")
# 2. PRE-PROCESS
# We boost contrast slightly to ensure blocks stay distinct
img = ImageEnhance.Contrast(img).enhance(1.05)
# 3. PIXELATE (The "Nearest" Secret)
# Using Image.NEAREST here prevents the "soft/blurry" edges
w, h = img.size
small_w, small_h = w // pixel_size, h // pixel_size
# Shrink using NEAREST to keep colors pure within the block
img_small = img.resize((small_w, small_h), resample=Image.Resampling.BOX)
# 4. COLOR REDUCTION (Removing the "Grain")
# Change dither=Image.NONE to get solid blocks of color.
# If you want a retro pattern, we can use a custom palette,
# but NONE is the king of "Blocky."
result = imagequant.quantize_pil_image(
img_small,
max_colors=224,
dithering_level=0, # Set to 0 for maximum BLOCKY look
min_quality=0, # from 0 to 100
max_quality=100, # from 0 to 100
)
# 5. UPSCALE
# We scale back up using NEAREST to keep the squares sharp
result = result.resize((w, h), resample=Image.NEAREST)
# Force back to RGB to save as PNG properly
result = result.convert("RGB")
result.save(output_path)
print(f"Blocky conversion complete: {output_path}")
if __name__ == "__main__":
# If you want it more blocky, increase pixel_size to 4 or 6.
make_blocky_pixel("input.png", "pixel_output.png", pixel_size=6)