Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Choose smaller of the two dimensions or make a perfect circle #17

Open
dannysood opened this issue May 6, 2017 · 8 comments
Open

Choose smaller of the two dimensions or make a perfect circle #17

dannysood opened this issue May 6, 2017 · 8 comments

Comments

@dannysood
Copy link

When width of image is bigger than height and it is taken as the radius the image drawn in circle is not perfect circle but a rectangle with two sides circular. Is ther ea way to force smaller of the two edges to be taken as reference. or maybe just fit the image the best way without losing orientation or aspect ratio in between a circle.

@ayushn21
Copy link
Owner

ayushn21 commented May 6, 2017

Hi @dannysood,

I considered this case when I originally wrote the library. I decided not to support it at the time because I couldn't think of a reason why a user would not lock the height equal to the width in AutoLayout if they wanted a circular profile picture.

I am still not keen on having this functionality in as I don't think it is required and would be unnecessary bloat in my opinion. Code would be required to compute the square in which to draw the circle and then centre it within the rectangular bounds. Fairly trivial logic, but no point in adding unnecessary code in!

Could you please explain what your use case is for which you would need this functionality?

Thanks,
Ayush

@dannysood
Copy link
Author

The reason I faced this issue is because I am trying to fetch images from social networks which may or may not be perfect squares. A lot of platforms allow you to upload pictures in any dimension and then select a part of it to show as thumbnail. As a result when such images are pulled and without the metadata of where the square thumbnail is its difficult to exactly how to draw the square thumbnail that can be converted to perfect circle. Doing aspect fit instead of aspect fill inside the circle when its drawn takes care of such scenarios in easy way. A lot of apps dont really want to complicate user flow and forcing user to select a dp in a cropping tool as a first step is a extra avoidable step when onboarding new customers which already is an expensive process.

@dannysood
Copy link
Author

I think I can figure out a way around it but this is something that other users may also feel and might expect this to be available as I expected. :)

@ayushn21
Copy link
Owner

ayushn21 commented May 8, 2017

Ah I see what you mean, you're referring to the dimensions of the image, not the ImageView.

I agree that a cropping tool is an extra avoidable step. Setting the image resizing to Aspect Fill would expand the image to fill the bounds of the ImageView, after which the circle shape would appear correctly.

This is something I would like to leave in control of the user though; in my opinion it is not within the scope of the library to handle those settings.

What are you thoughts on this? Is there a code change in the library code that you have in mind to work around this issue?

@dannysood
Copy link
Author

Setting the image resizing to Aspect Fill would expand the image to fill the bounds of the ImageView, after which the circle shape would appear correctly. This for some reason hasnt worked properly for me and I thought that this property was being bypassed somehow. THe image is always in aspectfit. The only special case here is that the uiimage is inside a stackview maybe that is to blame?

@ayushn21
Copy link
Owner

ayushn21 commented May 9, 2017

Ah, that's strange. I don't see why the Stack View should be a problem. I'm not setting the scaling mode anywhere inside the library. Could you please extract the bit of code you're facing a problem with into a sample project and upload it? It would help me investigate and diagnose the problem. Thanks!

@dannysood
Copy link
Author

Ill need some time for that. I am on a pretty tight deadline. You can go ahead and close this for now but I will get back to this with an update and we can reopen and debug it then.

@ayushn21
Copy link
Owner

No worries, I'll try investigating myself when I get some time. I'll leave it open in case someone else encounters the same issue :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants