holoizer 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- holoizer-0.1.0/LICENSE +15 -0
- holoizer-0.1.0/PKG-INFO +32 -0
- holoizer-0.1.0/README.md +17 -0
- holoizer-0.1.0/holoizer/__init__.py +2 -0
- holoizer-0.1.0/holoizer/cli.py +142 -0
- holoizer-0.1.0/holoizer/renderer.py +115 -0
- holoizer-0.1.0/holoizer.egg-info/PKG-INFO +32 -0
- holoizer-0.1.0/holoizer.egg-info/SOURCES.txt +12 -0
- holoizer-0.1.0/holoizer.egg-info/dependency_links.txt +1 -0
- holoizer-0.1.0/holoizer.egg-info/entry_points.txt +2 -0
- holoizer-0.1.0/holoizer.egg-info/requires.txt +3 -0
- holoizer-0.1.0/holoizer.egg-info/top_level.txt +1 -0
- holoizer-0.1.0/pyproject.toml +20 -0
- holoizer-0.1.0/setup.cfg +4 -0
holoizer-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 holoizer contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
holoizer-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: holoizer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Turn images into looping holographic card GIFs
|
|
5
|
+
License-Expression: ISC
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: numpy>=1.24
|
|
12
|
+
Requires-Dist: Pillow>=9.1
|
|
13
|
+
Requires-Dist: opencv-python-headless>=4.8
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# holoizer
|
|
17
|
+
|
|
18
|
+
Create looping holographic GIF cards from one image or a folder of images. Requires Python 3 with Pillow, NumPy and OpenCV (`pip install pillow numpy opencv-python`).
|
|
19
|
+
|
|
20
|
+
Install from a local source checkout with `python -m pip install .` or build a distribution with `python -m build`. After publishing to PyPI, it can be installed with `pip install holoizer`.
|
|
21
|
+
|
|
22
|
+
Use the installed command from a terminal:
|
|
23
|
+
|
|
24
|
+
```powershell
|
|
25
|
+
holoizer render "C:\path\image.png" -o "C:\path\card.gif"
|
|
26
|
+
holoizer render "C:\path\images" -o "C:\path\cards" --workers 2
|
|
27
|
+
holoizer benchmark "C:\path\image.png"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Folder mode processes supported images in the top-level folder, skips exact decoded-pixel duplicates and existing outputs, and writes `holoizer-report.json`. Use `--overwrite` to replace outputs. `--workers` controls concurrent processes and `--threads` controls OpenCV threads per process. Benchmarking runs full GIF renders to a temporary folder and reports the fastest tested CPU configuration. The current renderer uses CPU OpenCV, NumPy, and Pillow; it does not accelerate rendering on the GPU.
|
|
31
|
+
|
|
32
|
+
The effect uses a 48-frame perspective loop and a shared 256-color GIF palette. Resampling, rounded corners, effects and GIF quantization change the displayed pixels.
|
holoizer-0.1.0/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# holoizer
|
|
2
|
+
|
|
3
|
+
Create looping holographic GIF cards from one image or a folder of images. Requires Python 3 with Pillow, NumPy and OpenCV (`pip install pillow numpy opencv-python`).
|
|
4
|
+
|
|
5
|
+
Install from a local source checkout with `python -m pip install .` or build a distribution with `python -m build`. After publishing to PyPI, it can be installed with `pip install holoizer`.
|
|
6
|
+
|
|
7
|
+
Use the installed command from a terminal:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
holoizer render "C:\path\image.png" -o "C:\path\card.gif"
|
|
11
|
+
holoizer render "C:\path\images" -o "C:\path\cards" --workers 2
|
|
12
|
+
holoizer benchmark "C:\path\image.png"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Folder mode processes supported images in the top-level folder, skips exact decoded-pixel duplicates and existing outputs, and writes `holoizer-report.json`. Use `--overwrite` to replace outputs. `--workers` controls concurrent processes and `--threads` controls OpenCV threads per process. Benchmarking runs full GIF renders to a temporary folder and reports the fastest tested CPU configuration. The current renderer uses CPU OpenCV, NumPy, and Pillow; it does not accelerate rendering on the GPU.
|
|
16
|
+
|
|
17
|
+
The effect uses a 48-frame perspective loop and a shared 256-color GIF palette. Resampling, rounded corners, effects and GIF quantization change the displayed pixels.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""Render one image or a folder of images as holographic cards."""
|
|
2
|
+
import argparse
|
|
3
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
4
|
+
import hashlib
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import subprocess
|
|
9
|
+
import sys
|
|
10
|
+
import tempfile
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
import cv2
|
|
14
|
+
from PIL import Image, ImageOps
|
|
15
|
+
|
|
16
|
+
RENDERER = Path(__file__).with_name('renderer.py')
|
|
17
|
+
EXTENSIONS = {'.jpg', '.jpeg', '.png', '.webp', '.bmp', '.tif', '.tiff'}
|
|
18
|
+
|
|
19
|
+
def fingerprint(path):
|
|
20
|
+
with Image.open(path) as image:
|
|
21
|
+
image = ImageOps.exif_transpose(image).convert('RGBA')
|
|
22
|
+
return hashlib.sha256(str(image.size).encode() + image.tobytes()).hexdigest()
|
|
23
|
+
|
|
24
|
+
def run_one(source, output, threads):
|
|
25
|
+
env = os.environ.copy()
|
|
26
|
+
env['HOLOIZER_CV_THREADS'] = str(threads)
|
|
27
|
+
proc = subprocess.run([sys.executable, str(RENDERER), str(source), str(output)],
|
|
28
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, env=env)
|
|
29
|
+
if proc.returncode:
|
|
30
|
+
raise RuntimeError(proc.stderr.strip() or proc.stdout.strip())
|
|
31
|
+
with Image.open(output) as image:
|
|
32
|
+
if image.n_frames != 48:
|
|
33
|
+
raise ValueError(f'Expected 48 frames, found {image.n_frames}')
|
|
34
|
+
|
|
35
|
+
def render(args):
|
|
36
|
+
src = args.input.resolve()
|
|
37
|
+
if not src.exists():
|
|
38
|
+
raise ValueError(f'Input does not exist: {src}')
|
|
39
|
+
folder = src.is_dir()
|
|
40
|
+
sources = sorted((p for p in src.iterdir() if p.is_file() and p.suffix.lower() in EXTENSIONS), key=lambda p: p.name.lower()) if folder else [src]
|
|
41
|
+
if not sources:
|
|
42
|
+
raise ValueError('No supported images found')
|
|
43
|
+
out = args.output or (src.parent / (src.name + '-Cards') if folder else src.with_suffix('.gif'))
|
|
44
|
+
if folder:
|
|
45
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
46
|
+
else:
|
|
47
|
+
if out.suffix.lower() != '.gif':
|
|
48
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
49
|
+
out = out / (src.stem + '.gif')
|
|
50
|
+
out.parent.mkdir(parents=True, exist_ok=True)
|
|
51
|
+
seen, names, jobs, skipped, failures = {}, set(), [], [], []
|
|
52
|
+
for path in sources:
|
|
53
|
+
try:
|
|
54
|
+
digest = fingerprint(path)
|
|
55
|
+
if digest in seen:
|
|
56
|
+
skipped.append(f'{path.name}: duplicate of {seen[digest]}')
|
|
57
|
+
continue
|
|
58
|
+
seen[digest] = path.name
|
|
59
|
+
target = out / (path.stem + '.gif') if folder else out
|
|
60
|
+
if target.name.lower() in names:
|
|
61
|
+
target = out / (path.name + '.gif')
|
|
62
|
+
names.add(target.name.lower())
|
|
63
|
+
if target.exists() and not args.overwrite:
|
|
64
|
+
skipped.append(f'{path.name}: output exists')
|
|
65
|
+
continue
|
|
66
|
+
jobs.append((path, target))
|
|
67
|
+
except Exception as exc:
|
|
68
|
+
failures.append({'source': str(path), 'error': str(exc)})
|
|
69
|
+
print(f'{len(jobs)} to render, {len(skipped)} skipped; {args.workers} workers, {args.threads} OpenCV threads each', flush=True)
|
|
70
|
+
completed = []
|
|
71
|
+
def task(job):
|
|
72
|
+
path, target = job
|
|
73
|
+
# Write in the destination directory and replace only after successful validation.
|
|
74
|
+
tmp = target.with_name(target.name + '.partial.gif')
|
|
75
|
+
try:
|
|
76
|
+
run_one(path, tmp, args.threads)
|
|
77
|
+
tmp.replace(target)
|
|
78
|
+
finally:
|
|
79
|
+
tmp.unlink(missing_ok=True)
|
|
80
|
+
return str(target)
|
|
81
|
+
with ThreadPoolExecutor(max_workers=args.workers) as pool:
|
|
82
|
+
pending = {pool.submit(task, job): job[0] for job in jobs}
|
|
83
|
+
for future in as_completed(pending):
|
|
84
|
+
source = pending[future]
|
|
85
|
+
try:
|
|
86
|
+
output = future.result()
|
|
87
|
+
completed.append(output)
|
|
88
|
+
print(f'[{len(completed)+len(failures)}/{len(jobs)}] {output}', flush=True)
|
|
89
|
+
except Exception as exc:
|
|
90
|
+
failures.append({'source': str(source), 'error': str(exc)})
|
|
91
|
+
print(f'FAILED {source}: {exc}', file=sys.stderr, flush=True)
|
|
92
|
+
if folder:
|
|
93
|
+
(out / 'holoizer-report.json').write_text(json.dumps({'completed': completed, 'skipped': skipped, 'failed': failures}, indent=2), encoding='utf-8')
|
|
94
|
+
if failures:
|
|
95
|
+
raise RuntimeError(f'{len(failures)} image(s) failed')
|
|
96
|
+
|
|
97
|
+
def benchmark(args):
|
|
98
|
+
image = args.image.resolve()
|
|
99
|
+
if not image.is_file():
|
|
100
|
+
raise ValueError(f'Image not found: {image}')
|
|
101
|
+
print(f'OpenCV {cv2.__version__}; CPUs: {os.cpu_count()}; OpenCL available: {cv2.ocl.haveOpenCL()}; CUDA devices: {cv2.cuda.getCudaEnabledDeviceCount()}', flush=True)
|
|
102
|
+
print('Renderer uses CPU OpenCV and Pillow; GPU availability is informational, not a GPU benchmark.', flush=True)
|
|
103
|
+
results = []
|
|
104
|
+
with tempfile.TemporaryDirectory(prefix='holoizer-bench-') as temp:
|
|
105
|
+
for workers, threads in [(1, 1), (1, 2), (2, 1)]:
|
|
106
|
+
start = time.perf_counter()
|
|
107
|
+
with ThreadPoolExecutor(max_workers=workers) as pool:
|
|
108
|
+
futures = [pool.submit(run_one, image, Path(temp) / f'{workers}-{threads}-{i}.gif', threads) for i in range(workers)]
|
|
109
|
+
for future in futures:
|
|
110
|
+
future.result()
|
|
111
|
+
elapsed = time.perf_counter() - start
|
|
112
|
+
rate = workers / elapsed
|
|
113
|
+
results.append((rate, workers, threads))
|
|
114
|
+
print(f'{workers} worker(s), {threads} OpenCV thread(s): {elapsed:.1f}s, {rate:.3f} cards/s', flush=True)
|
|
115
|
+
_, workers, threads = max(results)
|
|
116
|
+
print(f'Fastest measured throughput: --workers {workers} --threads {threads}', flush=True)
|
|
117
|
+
|
|
118
|
+
def main():
|
|
119
|
+
parser = argparse.ArgumentParser(prog='holoizer', description='Make looping holographic cards from an image or a folder.')
|
|
120
|
+
commands = parser.add_subparsers(dest='command', required=True)
|
|
121
|
+
p = commands.add_parser('render', help='Render one image or all images in a folder')
|
|
122
|
+
p.add_argument('input', type=Path)
|
|
123
|
+
p.add_argument('-o', '--output', type=Path, help='GIF path or output folder')
|
|
124
|
+
p.add_argument('-j', '--workers', type=int, default=1, help='Parallel render processes (default: 1)')
|
|
125
|
+
p.add_argument('--threads', type=int, default=1, help='OpenCV threads per process (default: 1)')
|
|
126
|
+
p.add_argument('--overwrite', action='store_true', help='Replace existing GIFs')
|
|
127
|
+
p.set_defaults(func=render)
|
|
128
|
+
p = commands.add_parser('benchmark', help='Benchmark full CPU renders on this machine')
|
|
129
|
+
p.add_argument('image', type=Path)
|
|
130
|
+
p.set_defaults(func=benchmark)
|
|
131
|
+
args = parser.parse_args()
|
|
132
|
+
if args.command == 'render' and (args.workers < 1 or args.threads < 1):
|
|
133
|
+
parser.error('workers and threads must be positive')
|
|
134
|
+
try:
|
|
135
|
+
args.func(args)
|
|
136
|
+
except (ValueError, RuntimeError, OSError) as exc:
|
|
137
|
+
print(f'holoizer: {exc}', file=sys.stderr)
|
|
138
|
+
return 1
|
|
139
|
+
return 0
|
|
140
|
+
|
|
141
|
+
if __name__ == '__main__':
|
|
142
|
+
sys.exit(main())
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import cv2
|
|
3
|
+
import numpy as np
|
|
4
|
+
from PIL import Image, ImageDraw, ImageFilter
|
|
5
|
+
import sys
|
|
6
|
+
import os
|
|
7
|
+
cv2.setNumThreads(int(os.environ.get('HOLOIZER_CV_THREADS', '1')))
|
|
8
|
+
|
|
9
|
+
SOURCE = Path(sys.argv[1])
|
|
10
|
+
OUT = Path(sys.argv[2])
|
|
11
|
+
source_size = Image.open(SOURCE).size
|
|
12
|
+
W = 460
|
|
13
|
+
cw, ch = 320, round(320 * source_size[1] / source_size[0])
|
|
14
|
+
H = ch + 160
|
|
15
|
+
N = 48
|
|
16
|
+
rng = np.random.default_rng(47)
|
|
17
|
+
original = Image.open(SOURCE).convert('RGB').resize((cw, ch), Image.Resampling.LANCZOS)
|
|
18
|
+
base = np.asarray(original).astype(np.float32)
|
|
19
|
+
gray = cv2.cvtColor(base.astype(np.uint8), cv2.COLOR_RGB2GRAY).astype(np.float32) / 255
|
|
20
|
+
gx = cv2.Sobel(gray, cv2.CV_32F, 1, 0, ksize=3)
|
|
21
|
+
gy = cv2.Sobel(gray, cv2.CV_32F, 0, 1, ksize=3)
|
|
22
|
+
yy, xx = np.mgrid[0:ch, 0:cw].astype(np.float32)
|
|
23
|
+
dark = np.clip((.66-gray)*2, 0, 1)
|
|
24
|
+
border = np.clip((12-np.minimum.reduce([xx, yy, cw-1-xx, ch-1-yy]))/12, 0, 1)
|
|
25
|
+
bright = np.clip((gray-.68)*2.5, 0, 1)
|
|
26
|
+
mask_hi = Image.new('L', (cw*4, ch*4))
|
|
27
|
+
ImageDraw.Draw(mask_hi).rounded_rectangle((1, 1, cw*4-2, ch*4-2), radius=48, fill=255)
|
|
28
|
+
mask = np.asarray(mask_hi.resize((cw,ch), Image.Resampling.LANCZOS))
|
|
29
|
+
src = np.float32([[0,0],[cw-1,0],[cw-1,ch-1],[0,ch-1]])
|
|
30
|
+
Y, X = np.mgrid[0:H, 0:W].astype(np.float32)
|
|
31
|
+
vignette = np.clip(1-np.sqrt(((X-W/2)/(W*.8))**2+((Y-H/2)/(H*.8))**2),0,1)
|
|
32
|
+
stars = [(int(x),int(y)) for x,y in zip(rng.uniform(8,cw-8,45),rng.uniform(8,ch-8,45))]
|
|
33
|
+
particles = [(rng.uniform(0,W),rng.uniform(0,H),rng.uniform(0,2*np.pi),rng.uniform(.6,1.5)) for _ in range(30)]
|
|
34
|
+
anchors = [(int(cw*.69),int(ch*.12)),(int(cw*.51),int(ch*.30)),(int(cw*.22),int(ch*.22)),(int(cw*.84),int(ch*.65))]
|
|
35
|
+
|
|
36
|
+
def project(ax, ay, az, z, floating):
|
|
37
|
+
pts = np.array([[-cw/2,-ch/2,z],[cw/2,-ch/2,z],[cw/2,ch/2,z],[-cw/2,ch/2,z]],np.float32)
|
|
38
|
+
rx = np.array([[1,0,0],[0,np.cos(ax),-np.sin(ax)],[0,np.sin(ax),np.cos(ax)]])
|
|
39
|
+
ry = np.array([[np.cos(ay),0,np.sin(ay)],[0,1,0],[-np.sin(ay),0,np.cos(ay)]])
|
|
40
|
+
rz = np.array([[np.cos(az),-np.sin(az),0],[np.sin(az),np.cos(az),0],[0,0,1]])
|
|
41
|
+
p = pts @ (rz @ ry @ rx).T
|
|
42
|
+
scale = 1100/(1100-p[:,2])
|
|
43
|
+
return np.float32(np.column_stack((W/2+p[:,0]*scale,H/2+floating+p[:,1]*scale)))
|
|
44
|
+
|
|
45
|
+
def warp(image, quad, interpolation=cv2.INTER_LINEAR):
|
|
46
|
+
return cv2.warpPerspective(image, cv2.getPerspectiveTransform(src,quad), (W,H), flags=interpolation)
|
|
47
|
+
|
|
48
|
+
frames=[]
|
|
49
|
+
for i in range(N):
|
|
50
|
+
t=2*np.pi*i/N
|
|
51
|
+
ax=np.deg2rad(10.5)*np.sin(t+.5); ay=np.deg2rad(17.5)*np.sin(t); az=np.deg2rad(2.3)*np.sin(t+.9)
|
|
52
|
+
floating=7*np.sin(t+.4)
|
|
53
|
+
glow=np.exp(-(((X-W/2)/(W*.38))**2+((Y-(H/2+floating))/(H*.38))**2)*2)*(0.70+.15*np.sin(t))
|
|
54
|
+
bg=np.zeros((H,W,3),np.float32)
|
|
55
|
+
bg[:]=[4,10,20]; bg+=vignette[:,:,None]*np.array([3,12,20]); bg+=glow[:,:,None]*np.array([8,35,42])
|
|
56
|
+
bg=np.clip(bg,0,255).astype(np.uint8)
|
|
57
|
+
shadow=warp(mask,project(ax,ay,az,-10,floating))
|
|
58
|
+
shadow=cv2.GaussianBlur(shadow,(0,0),15).astype(np.float32)/255
|
|
59
|
+
shift=np.float32([[1,0,9-13*np.sin(t)],[0,1,20-5*np.sin(t+.5)]])
|
|
60
|
+
shadow=cv2.warpAffine(shadow,shift,(W,H))
|
|
61
|
+
bg=(bg*(1-shadow[:,:,None]*.72)).astype(np.uint8)
|
|
62
|
+
layer=Image.fromarray(bg); draw=ImageDraw.Draw(layer,'RGBA')
|
|
63
|
+
for x,y,phase,size in particles:
|
|
64
|
+
px=x+5*np.sin(t+phase); py=(y+7*np.cos(t+phase))%H
|
|
65
|
+
draw.ellipse((px-size,py-size,px+size,py+size),fill=(131,225,232,60))
|
|
66
|
+
bg=np.array(layer)
|
|
67
|
+
# Eight independently projected, brushed-metal depth slices.
|
|
68
|
+
for k in range(8,0,-1):
|
|
69
|
+
q=project(ax,ay,az,-k*1.25,floating)
|
|
70
|
+
a=warp(mask,q).astype(np.float32)/255
|
|
71
|
+
brush=(np.sin(yy*2.9+k)*8+np.sin(yy*.27)*5+74+18*np.sin(t+k*.18))
|
|
72
|
+
metal=np.stack([brush*.87,brush*1.03,brush*1.08],axis=2).clip(0,255).astype(np.uint8)
|
|
73
|
+
m=warp(metal,q); bg=(bg*(1-a[:,:,None])+m*a[:,:,None]).astype(np.uint8)
|
|
74
|
+
# Angle-driven diffraction is restrained over the subject to preserve detail.
|
|
75
|
+
phase=xx*.024+yy*.014+1.25*np.sin(t)
|
|
76
|
+
phase2=xx*.013-yy*.021+1.4*np.cos(t)
|
|
77
|
+
rainbow=np.stack([np.sin(phase),np.sin(phase+2.094),np.sin(phase+4.188)],2)*.5+.5
|
|
78
|
+
rainbow2=np.stack([np.sin(phase2+2),np.sin(phase2+4.094),np.sin(phase2+6.188)],2)*.5+.5
|
|
79
|
+
sweep=np.exp(-((xx/cw+yy/ch*.43-(.72+.75*np.sin(t)))/.075)**2)
|
|
80
|
+
sweep2=np.exp(-((xx/cw+yy/ch*.43-(.88+.75*np.sin(t)))/.025)**2)
|
|
81
|
+
spot=np.exp(-(((xx/cw-(.5+.38*np.sin(t)))**2)/.045+((yy/ch-(.3+.18*np.cos(t)))**2)/.07))
|
|
82
|
+
grating=(np.sin(xx*1.5+yy*1.8)+1)*.5
|
|
83
|
+
relief=np.clip((gx*np.cos(t)+gy*np.sin(t))*8,-14,14)
|
|
84
|
+
foil=(rainbow*18+rainbow2*11)*dark[:,:,None]*(.5+.5*grating[:,:,None])
|
|
85
|
+
img=base+foil+relief[:,:,None]+sweep[:,:,None]*13+sweep2[:,:,None]*15+spot[:,:,None]*8
|
|
86
|
+
img+=((bright*.09+border*.4)*sweep)[:,:,None]*np.array([50,39,15])
|
|
87
|
+
img+=border[:,:,None]*np.array([20,28,26])*(.55+.45*np.sin(t+yy[:,:,None]*.012))
|
|
88
|
+
img=np.clip(img,0,255).astype(np.uint8)
|
|
89
|
+
card=Image.fromarray(img); d=ImageDraw.Draw(card,'RGBA')
|
|
90
|
+
for x,y in stars:
|
|
91
|
+
a=int(35*(.5+.5*np.sin(t+x*.1+y*.03)))
|
|
92
|
+
d.point((x,y),fill=(177,237,255,a))
|
|
93
|
+
for x,y in anchors:
|
|
94
|
+
power=np.exp(-((x/cw+y/ch*.43-(.72+.75*np.sin(t)))/.12)**2)
|
|
95
|
+
length=2+int(10*power); alpha=int(90+140*power)
|
|
96
|
+
d.line((x-length,y,x+length,y),fill=(255,255,236,alpha),width=1)
|
|
97
|
+
d.line((x,y-length,x,y+length),fill=(255,255,236,alpha),width=1)
|
|
98
|
+
q=project(ax,ay,az,0,floating); a=warp(mask,q).astype(np.float32)/255
|
|
99
|
+
c=warp(np.array(card),q)
|
|
100
|
+
bg=np.clip(bg*(1-a[:,:,None])+c*a[:,:,None],0,255).astype(np.uint8)
|
|
101
|
+
layer=Image.fromarray(bg); d=ImageDraw.Draw(layer,'RGBA')
|
|
102
|
+
for x,y,phase,size in particles[::4]:
|
|
103
|
+
px=x+9*np.sin(t+phase); py=(y+10*np.cos(t+phase))%H
|
|
104
|
+
d.ellipse((px-size,py-size,px+size,py+size),fill=(190,239,255,120))
|
|
105
|
+
frames.append(layer)
|
|
106
|
+
print(f'Frame {i+1}/{N}',flush=True)
|
|
107
|
+
|
|
108
|
+
# Build one adaptive Median Cut palette from samples across the loop, then
|
|
109
|
+
# apply Floyd–Steinberg dithering consistently to every frame.
|
|
110
|
+
contact=Image.new('RGB',(W*4,H*3))
|
|
111
|
+
for j in range(12): contact.paste(frames[j*4],((j%4)*W,(j//4)*H))
|
|
112
|
+
palette=contact.quantize(colors=256,method=Image.Quantize.MEDIANCUT,dither=Image.Dither.NONE)
|
|
113
|
+
indexed=[f.quantize(palette=palette,dither=Image.Dither.FLOYDSTEINBERG) for f in frames]
|
|
114
|
+
indexed[0].save(OUT,save_all=True,append_images=indexed[1:],duration=45,loop=0,optimize=False,disposal=2)
|
|
115
|
+
print('Saved',OUT,OUT.stat().st_size)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: holoizer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Turn images into looping holographic card GIFs
|
|
5
|
+
License-Expression: ISC
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: numpy>=1.24
|
|
12
|
+
Requires-Dist: Pillow>=9.1
|
|
13
|
+
Requires-Dist: opencv-python-headless>=4.8
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# holoizer
|
|
17
|
+
|
|
18
|
+
Create looping holographic GIF cards from one image or a folder of images. Requires Python 3 with Pillow, NumPy and OpenCV (`pip install pillow numpy opencv-python`).
|
|
19
|
+
|
|
20
|
+
Install from a local source checkout with `python -m pip install .` or build a distribution with `python -m build`. After publishing to PyPI, it can be installed with `pip install holoizer`.
|
|
21
|
+
|
|
22
|
+
Use the installed command from a terminal:
|
|
23
|
+
|
|
24
|
+
```powershell
|
|
25
|
+
holoizer render "C:\path\image.png" -o "C:\path\card.gif"
|
|
26
|
+
holoizer render "C:\path\images" -o "C:\path\cards" --workers 2
|
|
27
|
+
holoizer benchmark "C:\path\image.png"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Folder mode processes supported images in the top-level folder, skips exact decoded-pixel duplicates and existing outputs, and writes `holoizer-report.json`. Use `--overwrite` to replace outputs. `--workers` controls concurrent processes and `--threads` controls OpenCV threads per process. Benchmarking runs full GIF renders to a temporary folder and reports the fastest tested CPU configuration. The current renderer uses CPU OpenCV, NumPy, and Pillow; it does not accelerate rendering on the GPU.
|
|
31
|
+
|
|
32
|
+
The effect uses a 48-frame perspective loop and a shared 256-color GIF palette. Resampling, rounded corners, effects and GIF quantization change the displayed pixels.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
holoizer/__init__.py
|
|
5
|
+
holoizer/cli.py
|
|
6
|
+
holoizer/renderer.py
|
|
7
|
+
holoizer.egg-info/PKG-INFO
|
|
8
|
+
holoizer.egg-info/SOURCES.txt
|
|
9
|
+
holoizer.egg-info/dependency_links.txt
|
|
10
|
+
holoizer.egg-info/entry_points.txt
|
|
11
|
+
holoizer.egg-info/requires.txt
|
|
12
|
+
holoizer.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
holoizer
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "holoizer"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Turn images into looping holographic card GIFs"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "ISC"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
dependencies = ["numpy>=1.24", "Pillow>=9.1", "opencv-python-headless>=4.8"]
|
|
14
|
+
classifiers = ["Programming Language :: Python :: 3", "Operating System :: OS Independent"]
|
|
15
|
+
|
|
16
|
+
[project.scripts]
|
|
17
|
+
holoizer = "holoizer.cli:main"
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.packages.find]
|
|
20
|
+
include = ["holoizer*"]
|
holoizer-0.1.0/setup.cfg
ADDED