question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loader option `fit` does not work

See original GitHub issue

Describe the bug

When I try to load an image which is rectangular and crop it to square:

<Image
  alt=""
  options={{
    fit: ImageFit.COVER,
  }}
  responsive={[
    {
      maxWidth: 800,
      size: {
        height: 800,
        width: 800,
      },
    },
  ]}
  src="https://images.unsplash.com/photo-1655241459367-c95abd34d0bc"
/>

It does not work, the image is distorted, it is not cropped. This part in url &width=800&height=800&fit=cover does not give me anything. On the other hand it works on unsplash (&fit=crop&w=500&h=500&q=80): https://images.unsplash.com/photo-1655241459367-c95abd34d0bc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=500&h=500&q=80

What I do wrong? 😃

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Try to create <Image /> with option fit: ImageFit.COVER. Inspect the image. It is not cropped.

Expected behavior

When we use fit: ImageFit.COVER and provided size of an image is different from its own ratio - it should be cropped.

Screenshots or Videos

Screenshot 2022-06-15 at 12 34 00

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Josh-McFarlincommented, Jun 27, 2022

@tomekrozalski Just wanted to mention that I incorporated changes into the latest releases of js-image-lib and Remix-Image to support fit and position in pureTransformer, so they can be used on all environments, not just those that support using Sharp

0reactions
Josh-McFarlincommented, Jun 15, 2022
export interface CropOptions {
  /** The x position of the upper left pixel. */
  x: number;
  /** The y position of the upper left pixel. */
  y: number;
  /** The number of pixels wide to crop the image. */
  width: number;
  /** The number of pixels high to crop the image. */
  height: number;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Doesn't work with webpack 2 · Issue #92 - GitHub
Hello guys. Looks like it doesn't works with the latest webpack 2 beta. loaders: [ { test: /\.css$/, loader: ExtractTextPlugin.extract({ ...
Read more >
"You may need an appropriate loader to handle this file type ...
All my index.js file is doing is importing react, but it seems like the 'babel-loader' is not working. I am using 'babel-loader ......
Read more >
Extending with Loaders - SurviveJS
The next question is how to pass a file name to the loader. Passing options to loaders#. To demonstrate passing options, the runner...
Read more >
FS19 - Fitting a front loader attachment - GIANTS Software
I've got a Claas Arion 610 tractor and FL140 front loader attachment but for the life of me I can't get the trigger...
Read more >
Loaders | Android Developers
Loaders make it easy to asynchronously load data in an activity or fragment. Loaders have these characteristics: There are multiple classes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found