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

[ASSETS-36125] Update SVG creation logic #216

Merged
merged 13 commits into from
Mar 18, 2024
Merged

[ASSETS-36125] Update SVG creation logic #216

merged 13 commits into from
Mar 18, 2024

Conversation

tmathern
Copy link
Member

@tmathern tmathern commented Mar 15, 2024

Description

We had some logic for default sizes of SVG files that only took width into account. This PR updates this logic to look at both width and height when picking (default) sizes for rendition generation.

Fixes # ASSETS-36125

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added updated tests to cover my changes.
  • All new and existing tests passed.

@tmathern tmathern self-assigned this Mar 15, 2024
Copy link
Member Author

@tmathern tmathern Mar 15, 2024

Choose a reason for hiding this comment

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

Seems there was no (visible) change in this rendition

Copy link
Member Author

Choose a reason for hiding this comment

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

Off-by-one change - logic change leads to width being 1 px smaller.

Copy link
Member Author

Choose a reason for hiding this comment

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

Off-by-one change - logic change leads to width being 1 px smaller.

@@ -1091,7 +1091,8 @@ describe("api.js", () => {
assert.ok(!fs.existsSync(renditionDir));
});

it('should send metrics - rendition and activation with cgroup metrics', async () => {
it.skip('should send metrics - rendition and activation with cgroup metrics', async () => {
Copy link
Member Author

@tmathern tmathern Mar 15, 2024

Choose a reason for hiding this comment

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

Flaky: sometimes (most often) hangs, sometimes runs. Keeping for local testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

is this hanging happening in prod too?

Copy link

codecov bot commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 55.35%. Comparing base (49d52a1) to head (3361e8c).
Report is 1 commits behind head on master.

Files Patch % Lines
lib/postprocessing/image.js 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #216      +/-   ##
==========================================
- Coverage   56.95%   55.35%   -1.60%     
==========================================
  Files          12       12              
  Lines         834      840       +6     
==========================================
- Hits          475      465      -10     
- Misses        359      375      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tmathern
Copy link
Member Author

Codecov Report

Attention: Patch coverage is 0% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 55.35%. Comparing base (49d52a1) to head (3361e8c).
Report is 1 commits behind head on master.

Files Patch % Lines
lib/postprocessing/image.js 0.00% 8 Missing ⚠️
Additional details and impacted files
☔ View full report in Codecov by Sentry. 📢 Have feedback on the report? Share it here.

Covered in the worker tests!

@tmathern tmathern marked this pull request as ready for review March 15, 2024 17:49
@@ -15,7 +15,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
node-version: [14.17]
node-version: [18.4.0]
Copy link
Member Author

@tmathern tmathern Mar 15, 2024

Choose a reason for hiding this comment

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

Even more tests hang/fail without this update, because when installing some libs warn of a bad (outdated) node engine.

@@ -634,13 +634,21 @@ async function imagePostProcess(intermediateRendition, rendition, directories) {

function convertSvg(img, instructions) {
// ImageMagick automatically keeps aspect ratio
// Only using width because ImageMagick will use the smallest value whether it be width or height
const width = instructions.width || SVG_DEFAULT_WIDTH;
let imageSize = SVG_DEFAULT_WIDTH;
Copy link
Member Author

Choose a reason for hiding this comment

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

Would be used only if nothing is set in instructions at all.

// image magick will keep aspect ratio
imageSize = `${instructions.width}x${instructions.height}`;
} else if(instructions.width) {
imageSize = `${instructions.width}x`;
Copy link
Member Author

@tmathern tmathern Mar 15, 2024

Choose a reason for hiding this comment

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

The x is left for clarity in the command param, to know we got width only (width is considered to be by default the first value in the command param).

Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to log wether we only got with or height or got both instead of having to examine the cmd?

} else if(instructions.width) {
imageSize = `${instructions.width}x`;
} else if(instructions.height) {
imageSize = `x${instructions.height}`;
Copy link
Member Author

@tmathern tmathern Mar 15, 2024

Choose a reason for hiding this comment

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

The x is left for clarity in the command param to know we got height only, and to make sure aspect ratio is kept, since height is the second param (and the first param, width, is "empty").

Copy link
Contributor

@jdelbick jdelbick left a comment

Choose a reason for hiding this comment

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

a few qs, but LGTM :)

// image magick will keep aspect ratio
imageSize = `${instructions.width}x${instructions.height}`;
} else if(instructions.width) {
imageSize = `${instructions.width}x`;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to log wether we only got with or height or got both instead of having to examine the cmd?

@@ -1091,7 +1091,8 @@ describe("api.js", () => {
assert.ok(!fs.existsSync(renditionDir));
});

it('should send metrics - rendition and activation with cgroup metrics', async () => {
it.skip('should send metrics - rendition and activation with cgroup metrics', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this hanging happening in prod too?

@tmathern tmathern merged commit badd5ae into master Mar 18, 2024
5 checks passed
@tmathern tmathern deleted the ASSETS-36125 branch March 18, 2024 16:51
@adobe-bot
Copy link

🎉 This PR is included in version 4.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants