Skip to content

images: replace swaps-redesign.svg with swaps-redesign.jpg#20703

Closed
legobeat wants to merge 7 commits intoMetaMask:developfrom
legobeat:compress-swaps-redesign
Closed

images: replace swaps-redesign.svg with swaps-redesign.jpg#20703
legobeat wants to merge 7 commits intoMetaMask:developfrom
legobeat:compress-swaps-redesign

Conversation

@legobeat
Copy link
Copy Markdown
Contributor

@legobeat legobeat commented Sep 3, 2023

Explanation

This image weighs in at 244kB (~1% of the entire metamask-extension bundle) - it's actually "not really" an svg but an embedded png. The base64 encoding adds extra overhead so just converting it to a .png should already save some space.

This converts it to a jpg (95% quality) to a size reduction to 90kB.

This converts it to a jpg (50% resize; 95% quality) to a filesize reduction to 33kB.

This converts it to a jpg (50% resize; 98% quality) to a filesize reduction to 43kB.

Related: #19169

Used ImageMagick for conversion:

$ for q in 30 40 50 60 65 70 75 80 85 90 92 95 96 98 99 100 ; do ; convert app/images/swaps-redesign.png -crop '10000x1118+0+10' -resize 50% -quality $q% app/images/swaps-redesign.$q-50.jpg ; done

Screenshots/Screencaps

Before

https://github.com/MetaMask/metamask-extension/blob/3d2de0211df1308a27897cfc60f8460120e93f7a/app/images/swaps-redesign.svg

After

https://github.com/MetaMask/metamask-extension/blob/5c8763d51c14056765112e9bd19a0e19668d2061/app/images/swaps-redesign.jpg

Manual Testing Steps

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 3, 2023

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@legobeat legobeat force-pushed the compress-swaps-redesign branch from 7d0d782 to d6039d0 Compare September 3, 2023 06:46
@legobeat legobeat marked this pull request as ready for review September 3, 2023 06:53
@legobeat legobeat requested a review from a team as a code owner September 3, 2023 06:53
@legobeat legobeat added the team-application-security Application security team label Sep 3, 2023
@legobeat legobeat requested a review from dan437 September 3, 2023 07:06
@legobeat legobeat force-pushed the compress-swaps-redesign branch 3 times, most recently from 186c915 to c2c4f05 Compare September 4, 2023 11:14
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8488e7a) 68.59% compared to head (9ad3f98) 68.70%.

❗ Current head 9ad3f98 differs from pull request most recent head eae3750. Consider uploading reports for the commit eae3750 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #20703      +/-   ##
===========================================
+ Coverage    68.59%   68.70%   +0.10%     
===========================================
  Files         1046     1042       -4     
  Lines        41613    41572      -41     
  Branches     11110    11097      -13     
===========================================
+ Hits         28543    28558      +15     
+ Misses       13070    13014      -56     

see 28 files with indirect coverage changes

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

@legobeat legobeat force-pushed the compress-swaps-redesign branch 2 times, most recently from 9b03313 to 277ada3 Compare September 10, 2023 02:42
@legobeat legobeat force-pushed the compress-swaps-redesign branch from 277ada3 to ff647d5 Compare September 12, 2023 05:42
@legobeat legobeat force-pushed the compress-swaps-redesign branch 3 times, most recently from ee455bc to 8c5dd98 Compare October 13, 2023 22:02
@legobeat legobeat requested a review from a team October 13, 2023 22:02
@Mrtenz
Copy link
Copy Markdown
Member

Mrtenz commented Oct 15, 2023

Can we instead make an actual SVG export of this image?

@legobeat
Copy link
Copy Markdown
Contributor Author

legobeat commented Oct 16, 2023

Can we instead make an actual SVG export of this image?

I guess that would be even better and preferred. I'm not sure how to get at that, though.. @dan437 ?

@davidmurdoch
Copy link
Copy Markdown
Contributor

Can we instead make an actual SVG export of this image?

I guess that would be even better and preferred. I'm not sure how to get at that, though.. @dan437 ?

I thought it'd be fun to see what Chat GPT-4 can do with a request to convert a png to an svg. It, uh, struggles:

converted_image

😆

@legobeat legobeat force-pushed the compress-swaps-redesign branch 2 times, most recently from ce590c3 to df3b4ac Compare October 23, 2023 07:37
@Mrtenz
Copy link
Copy Markdown
Member

Mrtenz commented Oct 23, 2023

swaps-thumbnail

This should be better. Thanks to @eriknson!

@legobeat
Copy link
Copy Markdown
Contributor Author

This should be better. Thanks to @eriknson!

@Mrtenz Hmm, that's still 67k (of which 19k is an embedded png; 30kB gzipped)... It's an improvement, but still on the large side and if it's possible to compress it somehow without degrading too much that would be even better.

@eriknson
Copy link
Copy Markdown
Contributor

Here's above SVG compressed to 49k. The only embedded png I could find in the design (not originally made by me, just reverse engineered for this) is the angled fox under "fetching quote". Can't think of any trivial way to vectorize that unfortunately

swaps-thumbnail (2)

@eriknson
Copy link
Copy Markdown
Contributor

I love svgs, but since this is for the What's new-modal, there's no transparency, and the max-width is pretty low; is a jpg sufficient?

If so, attached is 27k 📉

swaps-thumbnail-img

@legobeat
Copy link
Copy Markdown
Contributor Author

legobeat commented Oct 23, 2023

Removing that angled fox only from the latest svg brings it down to 32k (11k gzipped) if that's an option...

I suspect the gradients in the background account for a significant part, in case those are easily extractable and can be replaced with a border for the sake of the What's-new display.

@eriknson
Copy link
Copy Markdown
Contributor

Here's 30k w/out shadow & angled fox as an svg 😅

swaps-thumbnail-compressed

@legobeat legobeat requested a review from eriknson October 23, 2023 09:45
@legobeat legobeat force-pushed the compress-swaps-redesign branch from 052e0fb to 546a86a Compare October 24, 2023 01:52
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The dimensions and aspect ratio of the new image are different. Did you verify that this doesn't break anything in the extension?

Copy link
Copy Markdown
Contributor

@HowardBraham HowardBraham left a comment

Choose a reason for hiding this comment

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

Actually, I realized something important. This notification is dead anyway -- see line 1047 of selectors.js. We can just delete the image.

@legobeat legobeat mentioned this pull request Oct 25, 2023
13 tasks
@legobeat
Copy link
Copy Markdown
Contributor Author

Actually, I realized something important. This notification is dead anyway -- see line 1047 of selectors.js. We can just delete the image.

I guess the whole notification goes with it?

#21533

@legobeat legobeat force-pushed the compress-swaps-redesign branch 4 times, most recently from 24ed17a to d86ed2a Compare November 1, 2023 11:20
@legobeat legobeat force-pushed the compress-swaps-redesign branch from d86ed2a to d963379 Compare November 1, 2023 12:17
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 7, 2024

This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Jan 7, 2024
@github-actions
Copy link
Copy Markdown
Contributor

This PR was closed because there has been no follow up activity in the last 14 days. Thank you for your contributions.

@github-actions github-actions bot closed this Jan 21, 2024
HowardBraham added a commit that referenced this pull request Feb 13, 2024
## **Description**

Continues the work that @legobeat was doing in #20703 and #21533

All old numbered notifications except 8, 20, and 24 were permanently
turned off, but their code, their `messages.json`, and most importantly
their images were still present in the Extension.

By removing all this, we reduce the size of the zipped Extension by
949kB, and the unzipped Extension by 1,852kB.

**IMPORTANT**: This is **NOT** well-tested from a QA perspective, and QA
should do some good testing on it before we merge.

## **Related issues**

Followup to: #20703
Followup to: #21533

---------

Co-authored-by: legobt <6wbvkn0j@anonaddy.me>
sahar-fehri pushed a commit that referenced this pull request Feb 14, 2024
## **Description**

Continues the work that @legobeat was doing in #20703 and #21533

All old numbered notifications except 8, 20, and 24 were permanently
turned off, but their code, their `messages.json`, and most importantly
their images were still present in the Extension.

By removing all this, we reduce the size of the zipped Extension by
949kB, and the unzipped Extension by 1,852kB.

**IMPORTANT**: This is **NOT** well-tested from a QA perspective, and QA
should do some good testing on it before we merge.

## **Related issues**

Followup to: #20703
Followup to: #21533

---------

Co-authored-by: legobt <6wbvkn0j@anonaddy.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale issues and PRs marked as stale team-application-security Application security team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants