Share your code in style with this code beautifier and impress your followers. prettyCode allows you to include your name and avatar in the code so you will always be recognized when your code snippet goes viral, and express yourself by adding a video background.
prettyCode.online
prettyCode.online
prettyCode.online
from moviepy.editor import *
from PIL import Image, ImageEnhance, ImageFilter
import numpy as np
import os
# Paths
image_path = "/mnt/data/A_digital_image_in_a_semi-realistic,_illustrative_.png"
output_path = "/mnt/data/gangstar_animation.mp4"
# Load image with PIL
img = Image.open(image_path).convert("RGBA")
# Slight neon glow effect
glow = img.filter(ImageFilter.GaussianBlur(radius=8))
enhancer = ImageEnhance.Brightness(glow)
glow = enhancer.enhance(1.8)
# Merge glow with original
blended = Image.alpha_composite(glow, img)
# Save temp processed image
temp_path = "/mnt/data/temp_glow.png"
blended.save(temp_path)
# Create clip from processed image
clip = ImageClip(temp_path).set_duration(5)
# Zoom-in effect
zoom_in = clip.resize(lambda t: 1 + 0.05 * t) # slow zoom
# Add smoke effect (simple overlay using semi-transparent noise)
noise = np.random.randint(0, 255, (img.height, img.width, 3), dtype=np.uint8)
noise_img = Image.fromarray(noise).convert("RGBA").filter(ImageFilter.GaussianBlur(radius=15))
noise_alpha = 50 # transparency level
noise_layer = Image.new("RGBA", noise_img.size, (255, 255, 255, 0))
noise_layer.paste(noise_img, (0, 0), noise_img)
# Save smoke overlay
smoke_path = "/mnt/data/smoke.png"
noise_layer.save(smoke_path)
# Create smoke clip
smoke_clip = ImageClip(smoke_path).set_duration(5).set_opacity(0.2)
# Composite zoom with smoke
final_clip = CompositeVideoClip([zoom_in, smoke_clip])
# Write video
final_clip.write_videofile(output_path, fps=24)
output_path
STDOUT/STDERR
t: 40%|███▉ | 67/168 [01:49<01:33, 1.08it/s, now=None]Moviepy - Building video /mnt/data/gangstar_animation.mp4.
Moviepy - Writing video /mnt/data/gangstar_animation.mp4
t: 0%| | 0/120 [00:00<?, ?it/s, now=None][A
t: 2%|▏ | 2/120 [00:00<00:35, 3.32it/s, now=None][A
t: 2%|▎ | 3/120 [00:03<02:38, 1.35s/it, now=None][A
t: 3%|▎ | 4/120 [00:05<02:46, 1.43s/it, now=None][A
t: 4%|▍ | 5/120 [00:06<03:04, 1.61s/it, now=None][A
t: 5%|▌ | 6/120 [00:09<03:28, 1.83s/it, now=None][A
t: 6%|▌ | 7/120 [00:11<03:29, 1.86s/it, now=None][A
t: 7%|▋ | 8/120 [00:12<03:22, 1.80s/it, now=None][A
t: 8%|▊ | 9/120 [00:14<03:18, 1.79s/it, now=None][A
t: 8%|▊ | 10/120 [00:16<03:28, 1.90s/it, now=None][A
t: 9%|▉ | 11/120 [00:18<03:35, 1.98s/it, now=None][A
t: 10%|█ | 12/120 [00:20<03:29, 1.94s/it, now=None][A
t: 11%|█ | 13/120 [00:23<03:43, 2.09s/it, now=None][A
t: 12%|█▏ | 14/120 [00:25<03:47, 2.14s/it, now=None][A
t: 12%|█▎ | 15/120 [00:27<03:46, 2.16s/it, now=None][A
t: 13%|█▎ | 16/120 [00:30<03:54, 2.25s/it, now=None][A
t: 14%|█▍ | 17/120 [00:31<03:32, 2.06s/it, now=None][A
t: 15%|█▌ | 18/120 [00:33<03:26, 2.02s/it, now=None][A
t: 16%|█▌ | 19/120 [00:35<03:21, 1.99s/it, now=None][A
t: 17%|█▋ | 20/120 [00:37<03:19, 2.00s/it, now=None][A
t: 18%|█▊ | 21/120 [00:39<03:10, 1.93s/it, now=None][A
t: 18%|█▊ | 22/120 [00:40<02:58, 1.82s/it, now=None][A
t: 19%|█▉ | 23/120 [00:43<03:05, 1.91s/it, now=None][A
t: 20%|██ | 24/120 [00:45<03:07, 1.95s/it, now=None][A
t: 21%|██ | 25/120 [00:46<02:53, 1.83s/it, now=None][A
t: 22%|██▏ | 26/120 [00:48<02:57, 1.89s/it, now=None][A
t: 22%|██▎ | 27/120 [00:50<02:54, 1.87s/it, now=None][A
t: 23%|██▎ | 28/120 [00:52<02:52, 1.87s/it, now=None][A
t: 24%|██▍ | 29/120 [00:54<02:54, 1.91s/it, now=None][A