Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Readme
A python library to generate CSS gradient from an image. This is a fork of https://github.com/fraser-hemp/gradify. The original gradify project had only a CLI interface. With this fork, you can use gradify as a library in your Python code.
.. image:: https://user-images.githubusercontent.com/2115303/35187613-c6fe6fe8-fe3b-11e7-9b9d-3e088e460a1d.jpg
Install the latest release from PyPI:
.. code-block:: sh
pip install gradify
.. code-block:: python
gradify.generate_css(fp, single_color=False, use_color_spread=False)
fp
: a filename (string), pathlib.Path object or a file object.
The file object must implement read(), seek(), and tell() methods,
and be opened in binary mode.
single_color
: only produce a single, uniform background color -
this is much quicker and has all browser support
use_color_spread
: this flag will give the color which has the least
spread over the image the highest priority when assigning directions
(opposed to most dominant color). This feature improves overall accuracy,
however adds complexity and in unique cases it produces counter-intuitive results
Example:
.. code-block:: python
import gradify
css = gradify.generate_css('sample.png')
You can use Gradify
class for advanced usage.
.. code-block:: python
from gradify import Gradify
# simple usage
g = Gradify('sample.png', single_color=False, use_color_spread=False)
css = g.generate_css()
# advanced usage
g = Gradify('sample.png', single_color=False, use_color_spread=False, black_sensitivity=4.3,
white_sensitivity=3, num_colors=4, resize=55, uniformness=7, use_prefixes=False)
css = g.generate_css()
Default parameters produce good result.
From original repo:
The only suggestion is increasing the uniformness (by lowering it's value). It can improve
the general case, improve speed, but decrease the upper limits of accuracy.
Increasing sensitivity to black will do the same.
Many thanks to Fraser Hemphill
_ for writing the original gradify project.
MIT
.. _Fraser Hemphill
: https://github.com/fraser-hemp
FAQs
A python library to generate CSS gradient from an image
We found that gradify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).