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

fix: Don't return inputBuf if input is of type PDF #377

Merged
merged 2 commits into from
Oct 18, 2022

Conversation

KararTY
Copy link
Contributor

@KararTY KararTY commented Oct 18, 2022

Pull request checklist:

  • CHANGELOG.md was updated, if applicable

Description

Related to #374.

I have a maxThumbnailSize that is very high, which means that libvips default sizing for PDFs is within the limit, which is allowing this if check to return early:

// Only resize if the original image has bigger dimensions than maxThumbnailSize
if image.Width() <= maxThumbnailSize && image.Height() <= maxThumbnailSize {
// We don't need to resize image nor does it need to be passed through govips.
return inputBuf, nil
}

That early return of the inputBuf makes this happen:
image

Which definitely isn't intentional.

This PR adds an additional conditional to the if check and moves some things around to make the format variable work without crashing if image errors out. (Calling image.Format() when previous image, err := ... fails crashes the software, I learned.)

Images

Before:
image
After:
image

And yes, I have thumbnails set to size 900 in Chatterino.

@codecov
Copy link

codecov bot commented Oct 18, 2022

Codecov Report

Merging #377 (26e42f2) into master (a67a14d) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##           master     #377   +/-   ##
=======================================
  Coverage   45.34%   45.34%           
=======================================
  Files         100      100           
  Lines        3670     3670           
=======================================
  Hits         1664     1664           
  Misses       1959     1959           
  Partials       47       47           
Impacted Files Coverage Δ
pkg/thumbnail/thumbnail.go 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pajlada pajlada merged commit 0d62b5e into Chatterino:master Oct 18, 2022
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