Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for intervention/image:^3.4.0 #33

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kevindierkx
Copy link

@kevindierkx kevindierkx commented Feb 5, 2025

This PR's primary focus is to support intervention/image:^3.4.0, it comes with some breaking changes however.

Text wrapping

Wrapping of long sentences is now handled by intervention/image directly, truncating and the removal of lines of text that wouldn't fit in the containing 'box' is handled by the-og.

This heavily relies on the FontProcessor implementation of the used driver, eg. Imagick or Gd. Since we need to calculate the dimensions of a TextBox, to correctly calculate the 'anchor' point/position of related items, the 'canvas' ie. the ImageInterface has been moved from the feature's render method to an earlier stage using the added setCanvas() method. This is currently placed in the addFeature() method, called during the render cycle of the layout.

This modifies the signature of the render() method and will therefore break custom "Features".

Addition of the dimensions() method

The dimensions() method essentially replaces the getPrerenderedBox() and getRenderedBox() methods. The latter were primarily used to calculate anchors and line lengths. Unless a custom "Feature" would call these directly this shouldn't be as impactful.

Removal of the TextModifier implementation

This class was added at some point to calculate the bounding box of a text block. Since this is now directly handled in either the dimenstions() method or the TextBox implementation this class is now obsolete.

Driver agnostic improvements

Because we now directly interact with the image instance for various operations that would require a driver we don't need to initialise drivers or driver related instances ourself. Except for the PictureBox everything should now also work with GD, not sure if anyone was waiting for GD support... but hey it's there.

CTA placement fixes

Some default layouts were missing the preferred position, these have been added and the CTA element is now correctly displayed for all layouts.

Example output

Using the example from the docs, the image below is now the resulting output.

image

Copy link
Owner

@simonhamp simonhamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevindierkx this looks great but the tests are failing... I think you'll need to refresh the snapshots and commit those changes

@kevindierkx
Copy link
Author

kevindierkx commented Mar 7, 2025

@simonhamp I've update the snapshots. The placement of the first two using the avatar seems a little off:

The other snapshots word-wrap a little differently now when using the intevention wrapping logic, which would be expected.

I'll try to review those avatar layouts next week.

@simonhamp
Copy link
Owner

@kevindierkx and this one also has something up with the background repeating where it didn't repeat before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants