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

Control sizes of large images #146

Merged
merged 5 commits into from
Jul 7, 2022
Merged

Control sizes of large images #146

merged 5 commits into from
Jul 7, 2022

Conversation

buberdds
Copy link

@buberdds buberdds commented Jun 30, 2022

#143

Options:

  1. use official plugin-ideal-image to control large images

    • plugin is not bundled into @docusaurus/preset-classic preset like most of other official plugins
    • renaming to .mdx is not necessary, but might be good for third-party tools according to docs
  2. manually replace images in repo and don't add plugin-ideal-image

  3. Any other ideas?

  • 6b_ledger_oasis_ready does not need resizing. Switching to jpg is enough.

@buberdds buberdds requested a review from lukaw3d June 30, 2022 13:52
@netlify
Copy link

netlify bot commented Jun 30, 2022

Deploy Preview for trusting-archimedes-14c863 ready!

Name Link
🔨 Latest commit e4f6762
🔍 Latest deploy log https://app.netlify.com/sites/trusting-archimedes-14c863/deploys/62c7632e934b6e0008924979
😎 Deploy Preview https://deploy-preview-146--trusting-archimedes-14c863.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@matevz
Copy link
Member

matevz commented Jun 30, 2022

Nice catch. Can you also reformat the rest of the images in this PR accordingly and/or find substitutes?

@lukaw3d
Copy link
Member

lukaw3d commented Jun 30, 2022

@lukaw3d
Copy link
Member

lukaw3d commented Jun 30, 2022

option 2: manually replace images in repo and don't add plugin-ideal-image

I would prefer this, but sadly it won't reduce the repo size without rewriting history :/

@buberdds buberdds force-pushed the buberdds/controlImageSizes branch 2 times, most recently from b77b259 to 1dde93a Compare July 1, 2022 11:22
@lukaw3d
Copy link
Member

lukaw3d commented Jul 2, 2022

Tried to optimize with https://squoosh.app/. docs/docs folder size: 43.9 MB -> 13.1 MB

Seems like jpgs lost some vibrancy.

@buberdds
Copy link
Author

buberdds commented Jul 5, 2022

Thanks for sharing, never heard about it before. Will explore options with resizing now.

@buberdds buberdds force-pushed the buberdds/controlImageSizes branch from 148289f to 823e2ac Compare July 6, 2022 11:18
@lukaw3d lukaw3d force-pushed the buberdds/controlImageSizes branch 2 times, most recently from 3e91a1f to 56170b5 Compare July 6, 2022 17:47
@buberdds buberdds force-pushed the buberdds/controlImageSizes branch from d52a368 to 94a3f0b Compare July 6, 2022 21:18
@buberdds buberdds requested a review from matevz July 6, 2022 21:26
@matevz
Copy link
Member

matevz commented Jul 7, 2022

Why did image brightness change? e.g. https://github.com/oasisprotocol/docs/pull/146/files#diff-c8ac17fbe04959322612fa9ece20f8c658da0ab93ce11bf35368b8d505a8ddb5

I think screenshots should be as they are. Lossless compression and resolution reduction from highdpi desktops are ok, but not changing colors/brightness.

Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

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

Good work. Just check why the brightness of some images changed.

@tjanez
Copy link
Member

tjanez commented Jul 7, 2022

but not changing colors/brightness.

I wouldn't worry about brightness too much currently.

Let's rather make sure we have a process that will prevent uploading PNG images that can't be compressed well.

Copy link
Member

@tjanez tjanez left a comment

Choose a reason for hiding this comment

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

Thanks, @buberdds!

@tjanez
Copy link
Member

tjanez commented Jul 7, 2022

Follow up issues: #153 and #154.

// imagemagick to convert to sRGB color profile
convert 6b_ledger_oasis_ready.png -profile /usr/share/color/icc/colord/sRGB.icc\
  -strip 6b_ledger_oasis_ready.png

// @squoosh/cli to reduce file size
npx squoosh-cli --mozjpeg '{"quality":75}' 6b_ledger_oasis_ready.png
shopt -s globstar
for i in docs/**/*.png; do
  # imagemagick to convert to sRGB color profile
  convert "$i" -profile /usr/share/color/icc/colord/sRGB.icc -strip "$i"
  # @squoosh/cli to reduce file size
  npx squoosh-cli \
    --quant '{"enabled": true, "zx": 0, "maxNumColors": 256, "dither": 1}' \
    --oxipng '{"level":2,"interlace":false}' --output-dir "`dirname $i`" "$i"
done
shopt -s globstar
for i in docs/**/*.jpg; do
  # imagemagick to convert to sRGB color profile
  convert "$i" -profile /usr/share/color/icc/colord/sRGB.icc -strip "$i"
  # @squoosh/cli to reduce file size
  npx squoosh-cli --mozjpeg '{"quality":75}' --output-dir "`dirname $i`" "$i"
done
@lukaw3d lukaw3d force-pushed the buberdds/controlImageSizes branch from 94a3f0b to e4f6762 Compare July 7, 2022 22:50
@lukaw3d
Copy link
Member

lukaw3d commented Jul 7, 2022

Fixed colors by converting from "DELL U3818DW" color profile to "sRGB" and then removing it
convert "$i" -profile /usr/share/color/icc/colord/sRGB.icc -strip

@lukaw3d lukaw3d merged commit f29d021 into main Jul 7, 2022
@lukaw3d lukaw3d deleted the buberdds/controlImageSizes branch July 7, 2022 22:54
@tjanez
Copy link
Member

tjanez commented Jul 8, 2022

Fixed colors by converting from "DELL U3818DW" color profile to "sRGB" and then removing it
convert "$i" -profile /usr/share/color/icc/colord/sRGB.icc -strip

Nice 🙂

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.

4 participants