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

Scaled images can break Sharp resizing #62

Closed
ashleahhill opened this issue Aug 21, 2019 · 1 comment · Fixed by #63
Closed

Scaled images can break Sharp resizing #62

ashleahhill opened this issue Aug 21, 2019 · 1 comment · Fixed by #63

Comments

@ashleahhill
Copy link
Contributor

I have an image that is 2593px wide and I want to scale it down by half.

I am using https://github.com/TrigenSoftware/flexis-srcset-loader. My config can be seen here: TrigenSoftware/flexis-srcset-loader#16

Error: Expected positive integer for width but received 1296.5 of type number
    at Object.invalidParameterError (<project_path>/node_modules/@flexis/srcset/node_modules/sharp/lib/is.js:101:10)
    at Sharp.resize (<project_path>/node_modules/@flexis/srcset/node_modules/sharp/lib/resize.js:197:16)
    at SrcsetGenerator.processImage (<project_path>/node_modules/@flexis/srcset/lib/index.js:312:19)
    at <project_path>/node_modules/@flexis/srcset/lib/index.js:269:56
    at Generator.next (<anonymous>)
    at resume (<project_path>/node_modules/@flexis/srcset/node_modules/@babel/runtime/helpers/AsyncGenerator.js:27:28)
    at <project_path>/node_modules/@flexis/srcset/node_modules/@babel/runtime/helpers/AsyncGenerator.js:20:9
    at new Promise (<anonymous>)
    at AsyncGenerator.send [as _invoke] (<project_path>/node_modules/@flexis/srcset/node_modules/@babel/runtime/helpers/AsyncGenerator.js:7:12)
    at AsyncGenerator.next (<project_path>/node_modules/@flexis/srcset/node_modules/@babel/runtime/helpers/AsyncGenerator.js:89:15)
    at Promise.all.rules.map (<project_path>/node_modules/@flexis/srcset-loader/lib/index.js:204:95)

I think the issue is calculatedWidth:

const calculatedWidth = originWidth && width <= 1 ? width * originWidth : width;

The true value should be rounded before assigning.

@dangreen
Copy link
Member

@ashleahhill thank you for pr, fix was published.

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 a pull request may close this issue.

2 participants