
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
The Krita Python Library provides a simple and intuitive way to programmatically create and manipulate Krita (.kra) files. It supports creating documents with multiple layers, including text, shapes, and images.
pip install kritapy
from kritapy import KritaDocument, TextStyle, ShapeStyle, ShapeLayer
# Create a new document
doc = KritaDocument(width=1280, height=1024)
# Add some content
doc.add_text_layer("Hello Krita!")
doc.add_image_layer("background.jpg")
# Save the document
doc.save("output.kra")
The main class for creating and managing Krita documents.
doc = KritaDocument(width=1280, height=1024)
Parameters:
width
(int): Document width in pixels (default: 1024)height
(int): Document height in pixels (default: 1024)Text layers can be created in two ways:
doc.add_text_layer(
text="Hello Krita!",
name="My Text",
x=100,
y=100
)
text_style = TextStyle(
font_family="Arial",
font_size=24,
fill_color="#000000",
stroke_color="#FFFFFF",
stroke_width=1,
stroke_opacity=1.0,
letter_spacing=0,
text_align="start"
)
text_layer = ShapeLayer.from_text(
text="Hello\nMultiline Text",
name="Styled Text",
x=100,
y=100,
style=text_style
)
doc.add_text_layer(text_layer)
Add raster images to your document:
doc.add_image_layer(
image="path/to/image.jpg", # Can be path or PIL Image
name="Background",
opacity=255,
x=0,
y=0
)
Create vector shapes using various primitives:
from krita_lib import Rectangle, Circle, Ellipse, Line, Path, ShapeGroup
# Create shape style
shape_style = ShapeStyle(
fill="#FF0000",
stroke="#000000",
stroke_width=2.0,
stroke_opacity=1.0,
fill_opacity=0.5
)
# Create shapes
rect = Rectangle(
x=100,
y=100,
width=200,
height=150,
rx=10, # rounded corners
style=shape_style
)
circle = Circle(
cx=300,
cy=300,
r=50,
style=shape_style
)
# Add shapes to document
doc.add_shape_layer(
ShapeGroup([rect, circle]),
name="My Shapes"
)
Create complex vector paths using SVG path commands:
path = Path(
d="M 100 100 L 200 100 L 150 50 Z", # Triangle
style=ShapeStyle(
fill="#00FF00",
stroke="#000000",
stroke_width=2
)
)
doc.add_shape_layer(path, name="Path Layer")
Common SVG Path Commands:
M x y
- Move toL x y
- Line toH x
- Horizontal lineV y
- Vertical lineQ x1 y1 x y
- Quadratic curveC x1 y1 x2 y2 x y
- Cubic curveZ
- Close pathfont_family
: Font name (e.g., "Arial")font_size
: Font size in pointsfill_color
: Text color in hex formatstroke_color
: Outline colorstroke_width
: Outline widthstroke_opacity
: Outline opacity (0-1)letter_spacing
: Space between lettersword_spacing
: Space between wordstext_align
: Text alignment ("start", "end", "center", "justify")line_height
: Line spacing multiplieruse_rich_text
: Enable rich text formattingtext_rendering
: Text rendering modefill
: Fill color or "none"stroke
: Stroke colorstroke_width
: Stroke widthstroke_opacity
: Stroke opacity (0-1)fill_opacity
: Fill opacity (0-1)stroke_linecap
: Line endings ("butt", "round", "square")stroke_linejoin
: Line joins ("miter", "round", "bevel")stroke_dasharray
: Dash pattern (e.g., "5,5")from krita_lib import (
KritaDocument, TextStyle, ShapeStyle,
ShapeLayer, Rectangle, Circle, Path, ShapeGroup
)
# Create document
doc = KritaDocument(width=1280, height=1024)
# Add styled text
text_style = TextStyle(
font_family="Arial",
font_size=24,
fill_color="#000000",
stroke_color="#FFFFFF",
stroke_width=1
)
text_layer = ShapeLayer.from_text(
text="Hello Krita!\nMultiline Text",
name="Title",
x=100,
y=100,
style=text_style
)
doc.add_text_layer(text_layer)
# Add shapes
shape_style = ShapeStyle(
fill="#FF0000",
stroke="#000000",
stroke_width=2
)
shapes = [
Rectangle(x=80, y=80, width=300, height=150, rx=10, style=shape_style),
Circle(cx=230, cy=155, r=100, style=shape_style),
Path(
d="M 100 150 Q 130 140, 160 150 Q 190 160, 220 150",
style=ShapeStyle(fill="none", stroke="#0000FF", stroke_width=2)
)
]
doc.add_shape_layer(ShapeGroup(shapes), name="Decorative Shapes")
# Add background image
doc.add_image_layer("background.jpg", name="Background")
# Save the document
doc.save("output.kra")
The library throws standard Python exceptions:
TypeError
: Invalid parameter typesValueError
: Invalid parameter valuesFileNotFoundError
: Missing image filesOSError
: File system related errorsContributions are welcome! Please check our GitHub repository for guidelines.
FAQs
Python library for creating and manipulating Krita documents programmatically
We found that kritapy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.