Jump to content

ScaleType or fitWidth/fitHeight for images


sonicsound

Recommended Posts

sonicsound

Hi, 

 

I'd like to be able to render photos at a fixed size center cropped. Currently, setting both Width & Height with an image request causes the aspect ratio to be adjusted. It would be awesome to be able to pass a scaleType=centerCrop (or equivalent) param to specify that the aspect ratio be maintained, and the image cropped to fit the dimensions.

 

Alternatively, if there was a way to specify fitWidth/fitHeight params that ensure that both dimensions are at least as large as the specified dimensions (minimally), then the cropping could be done on the client.

 

Thanks!

Link to comment
Share on other sites

sonicsound

Hey,

 

using MaxWidth/MaxHeight in this case would require knowing the aspect ratio of the image upfront. 

 

ex.

Original = 1600x800

Target = 400x400

 

requesting MaxWidth=400&MaxHeight=400 results in 400x200 image, but the desired behavior would be to return 800x400 so that the image can be cropped without quality loss.

 

Since photos can include a combination of landscape and portrait orientation, I can't specify only MaxWidth either

Link to comment
Share on other sites

Right, I'm only mentioning it because as of today that's the closest thing we have to what you're looking for, thanks.

Link to comment
Share on other sites

Since photos can include a combination of landscape and portrait orientation, I can't specify only MaxWidth either

 

You could use MaxHeight though...

Link to comment
Share on other sites

sonicsound

... that would have the same issue. The problem is that you need to know the original aspect ratio before loading the image with the currently available options.

Link to comment
Share on other sites

FYI emby apps do not always have that information and they are able to show images using maxwidth/maxheight without loss of aspect ratio.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...