0

I want to resize an image with lets say 980:1000 to an aspect ratio of 1:1, or an Image with 1500:900 to 16:9. How can I do that ? I only want Images to get smaller so they dont get stretched (980:1000 to for example 980:980).

cb4
  • 6,689
  • 7
  • 45
  • 57

3 Answers3

0

Is this in a browser? The easiest method is probably using background-size:cover.

http://css-tricks.com/perfect-full-page-background-image/

html { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
Will Shaver
  • 12,471
  • 5
  • 49
  • 64
0

Why not use CSS?

To Responsive Image:

img {
    max-width: 100%;
    height: auto;
}

_

>StackOverflow question (JSFiddle)

>Another tricks

>Rundown of Handling Flexible Media

>Why Responsive Images Is So Hard

Community
  • 1
  • 1
rafaeldefazio
  • 449
  • 2
  • 7
0

You can do this by placing the image inside a wrapper element and giving the size to wrapper and overflow property to hidden so that image appears to be cropped yet its not stretched.

<div style="overflow:hidden; height:980px; width: 980px;" > <img src="img_1000x980.jpg" /> </div>

Bhavesh B
  • 1,121
  • 12
  • 25