A challenge on the web page is to display images in a square format of 90 * 90 pixels. However, the sizes of these images are not consistent and may vary from 80*100 to 100*80 or even 90 * 110.
The requested solution is to stretch the image as follows:
1) If an image has a width of 45 and height of 100, it should be stretched to a width of 90 and height of 200 while displaying only the top 90 pixels.
2) If an image has a width of 100 and height of 45, it should be stretched to a width of 200 and height of 90 while displaying only the left 90 pixels.
In essence, the aim is to always show the top-left portion of the image within a 90*90 size frame.
What would be the solution for achieving this using JavaScript and CSS? Thank you