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.

/fit-in not working with 4.0.0

See original GitHub issue

Using /fit-in/AxB/ is cropping images rather than fitting them within the dimensions specified.

Example: https://i1rk6c9qi5.execute-api.us-east-1.amazonaws.com/image/100x100/bart.png

A workaround to fit an image into the resize area is to use the upscale filter:

https://i1rk6c9qi5.execute-api.us-east-1.amazonaws.com/image/200x50/filters:upscale()/bart.png

The fix for this might be in the process(event) function:

https://github.com/awslabs/serverless-image-handler/blob/a1b3eb659807599eaec88fb8df21bc34a45b93ee/source/image-handler/thumbor-mapping.js#L27-L38

… the this.edits.resize.fit = 'inside' needs to be set, the same as what happens in the upscale() filter.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
beomseokleecommented, Feb 6, 2020

We have updated our solution, and I believe your issue has been fixed. If you still see the issue with the latest version (v4.2), please feel free to reopen the issue.

You can refer to the recent changes here

1reaction
mandyscommented, Jul 15, 2019

Hi @tjw0051 we faced a similar issue. fit-in from thumbor isn’t translated here correctly.

That’s because they aren’t passing anything to resize. While ‘inside’ is the right way forward ( because it preserves aspect ratio ) for us this leads to another issue. For eg: if we pass 500x500 as the size, we want image to be resized based on aspect ratio but we should be able to ‘fill’ the remaining area with color of our choice.

This is how we did in thumbor:

https://<our_cf_url>/fit-in/500x500/filters:quality(90):fill(fff)/my_source.jpg

If we use ‘inside’, we get back an image with aspect ratio maintained, but we aren’t able to fill it with white color so as to get back 500x500 final product.

options.background can only be used with ‘contain’. https://sharp.pixelplumbing.com/en/stable/api-resize/

So, if this was instead using

this.edits.resize.fit = ‘contain’,

we could pass

sharp(input) .resize(200, 300, { kernel: sharp.kernel.nearest, fit: ‘contain’, position: ‘right top’, background: { r: 255, g: 255, b: 255, alpha: 0.5 } }) .toFile(‘output.png’) .then(() => { // output.png is a 200 pixels wide and 300 pixels high image // containing a nearest-neighbour scaled version // contained within the north-east corner of a semi-transparent white canvas });

Read more comments on GitHub >

github_iconTop Results From Across the Web

fit-in not working with 4.0.0 · Issue #114 - GitHub
Using /fit-in/AxB/ is cropping images rather than fitting them within the dimensions specified.
Read more >
Could not load file or assembly "System.Net.Http, Version=4.0 ...
Net.Http v 4.0.0 , i just installed System.Net.Http nuget package in my startup project and the problem solved ... This will work in...
Read more >
Dealing with R 4.0 - RStan - The Stan Forums
I've found out that this is a problem of the package parallel from R-4.0.0 I've found this recently issue in RStudio's GitHub that...
Read more >
Runtime Changes for Migration from .NET Framework 4.0 to 4.8
Find information about application compatibility issues from runtime changes that might affect your app when migrating from .
Read more >
Upgrade to Prisma 4
Prisma 4 introduces a number of breaking changes when you upgrade from an earlier Prisma version. This guide explains how this upgrade might...
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