Small Python library with a single purpose to apply fast blur to PNG images (libpng backend)
Project description
pyfastblur
Small Python library with a single purpose to apply fast blur to PNG images (libpng backend)
Usage
# example 1
import pyfastblur
result = pyfastblur.blur("path/to/file.png", radius=24)
# example 2
result = pyfastblur.blur("path/to/file.png",
radius=24,
stronger_blur=True)
# stronger_blur makes additional blur passes, is much slower
# example 3
from io import BytesIO
# read image into memory object
obj = BytesIO()
with open("test.png", 'rb') as f:
obj.write(f.read())
# rewind
obj.seek(0)
result = pyfastblur.blur(obj, radius=24)
# write result to file
with open("output.png", 'wb') as f:
f.write(result.read())
Speed
Sample image: link (3.55MB)
Code:
import pyfastblur
import time
from io import BytesIO
runs = 6
average = 0.0
for i in range(runs):
start = time.time()
# read image into memory object
obj = BytesIO()
with open("test.png", 'rb') as f:
obj.write(f.read())
# rewind
obj.seek(0)
# output: BytesIO object
out = pyfastblur.blur(obj, radius=64)
# write to file
with open("output.png", 'wb') as f:
f.write(out.read())
average += (time.time() - start)
average = average / runs
print("Average runtime: %s seconds" % str(average))
Result (Windows): Average runtime: 0.5009152094523112 seconds
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyfastblur-1.0.tar.gz
(539.4 kB
view hashes)
Built Distribution
Close
Hashes for pyfastblur-1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 514573b51c413b6adb4921c5494448e64547d7b27c990b6959fee79087cf35fa |
|
MD5 | f0b2bd3a41bfb8c2882a3739a7029060 |
|
BLAKE2b-256 | 52f8f1cf0f38665f7a37fc982ce74f77eeb81a5960adca79750e5d3e8243e488 |