Repository navigation
Releases: yilanboy/preview
Releases · yilanboy/preview
Release list
2.4.0
2.3.0
What's Changed
- chore(deps-dev): bump the composer-version group across 1 directory with 2 updates by @dependabot[bot] in #10
- Feat/add quality option by @yilanboy in #11
Full Changelog: 2.2.0...2.3.0
2.2.0
Added
- New
Fontcases adding a Medium (500) weight for every bundled family, plus a new monospaced family:InterMedium,
RobotoMedium,JetBrainsMono,JetBrainsMonoMedium,NotoSansMedium,NotoSansSCMedium,NotoSansTCMedium, and
NotoSansJPMedium. Each family now ships a Regular (400) and a Medium (500) variant.
Changed
- Bundled fonts are now static TrueType instances instead of variable fonts, so GD renders the intended weight and
optical size (imagettftextcannot select an axis from a variable font). This changes the rendered output of the
existingFont::Inter(now the 24pt optical cut),Font::Roboto, andFont::NotoSanscases — regenerate any cached
images after upgrading.
2.1.0
Added
- Added
Generator::bytes()to return encoded image bytes as a string. - Added Laravel/framework-friendly usage examples for returning responses and storing generated images.
Changed
- Documented
bytes()as a third output method alongsideoutput()andsave().
Fixed
- Improved image byte test coverage across
PNG,JPEG, andWEBPformats.
2.0.0
The first stable 2.0 release. This is a ground-up rewrite of the rendering
pipeline with a new Generator entry point, composable backgrounds, accurate
font metrics, and multi-language text support. It consolidates everything from
2.0.0-beta.1 through 2.0.0-beta.4.
Upgrading from 1.x? This release is not backward compatible — see
Breaking Changes below. Install withcomposer require yilanboy/preview:^2.0.
💥 Breaking Changes
- Minimum PHP is now
^8.4(was^8.2). Image\Builderis replaced byGeneratoras the main entry point — an API
rename, not backward compatible.Color\Converteris replaced by a top-levelColorConverterwith static
methods; dependency injection removed.- The
backgroundColorshortcut is removed. Backgrounds are now configured
via dedicated background classes (Solid,Gradient,Image). - Background interfaces moved into a
Contractsnamespace (Contracts\Background). - Text handling reworked around a new
TextBlockvalue object and an internal
layout engine.
✨ Added
- Composable backgrounds (
Yilanboy\Preview\Canvas):Solid— a flat color.Gradient— two-color interpolation with aGradientDirectionenum
(Vertical,Horizontal,Diagonal).Image— a bitmap background with anImageFitenum (Cover,Contain,
Stretch,Tile), configurableopacity, and atintcolor.
TextBlockvalue object (immutable,final readonly) for title and
description text, withFont,FontSize,Alignment,LineHeight, and
Positionenums. Title and description stack without overlapping.- Custom TrueType fonts — pass a
.ttffile path, validated on construction
(OpenType / non-TTF files are rejected). - Multi-language text rendering for Traditional Chinese, Simplified Chinese,
and Japanese, with appropriate word/character wrapping. - Custom canvas sizes and font sizes —
Generator::dimensions(int, int)and a
custom integer pixelFontSize, both validated (InvalidInputbelow1). Size,Margin, andFormatenums for canvas presets and output encoding.- Typed exceptions in a new
Exceptionsnamespace:InvalidInputand
RenderFailure, both implementing thePreviewExceptionmarker interface.
Backward compatible — they still extend the SPL exceptions the library threw
before, so existing catch blocks keep working. - Color validation enforced at construction across all color-accepting types
viaColorConverter::isValidColor()(named colors or hex).
🛠 Improved & Fixed
- Accurate line height derived directly from the font's
head/hheasfnt
tables (via a newLineMetricsvalue object) instead of glyph bounding-box
probing. - More robust font parsing — sfnt tables are validated and binary unpacking
errors are handled gracefully, throwingRenderFailureon corrupt font files. - Faster rendering — text lines are measured once during wrapping and reused
at placement;Imagebackgrounds decode the source file once and cache the
bitmap.
Full Changelog: 1.0.1...2.0.0