Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cropping Photo, with out photoshop 1

Status
Not open for further replies.

zbphill

Technical User
Jan 30, 2007
40
US
I want to crop a picture (.jpg) using HTMl, CSS, Javascrip, ect.
I know how to in photoshop, and all the other programs.

I have clients uploading pictures(random height and width) and the pictures get displayed on the web, but I want them a to be all to be display a certain size with out stretching the picture.

Any Idea, tutorials, or programs out there.

thanks
Zach
 
Put each picture in its own floated DIV set to the dimensions you want and specifying "overflow:hidden":

Code:
<div style="width:200px; height:200px; overflow:hidden; float:left; border:thin solid" 
[&nbsp;]
</div>
<div style="width:200px; height:200px; overflow:hidden; float:left; border:thin solid" 
<img src="pic2.jpg" />
</div>
<div style="width:200px; height:200px; overflow:hidden; float:left; border:thin solid" 
<img src="pic3.jpg" />
</div>
<div style="width:200px; height:200px; overflow:hidden; float:left; border:thin solid" 
<img src="pic4.jpg" />
</div>
<div style="width:200px; height:200px; overflow:hidden; float:left; border:thin solid" 
<img src="pic5.jpg" />
</div>
The top left portion of each picture is displayed and the remainder is cropped. Of course you'll want to specify the style in the STYLE section, not inline as I did here.

The downside is that the entire picture is served even though only part is displayed, so extra unnecessary bandwidth is consumed.

Mike Krausnick
Dublin, California
 
From the same article referenced above:
The CSS clip property has to be one of the least used properties in CSS. This is probably because no one really knows when to use it, it doesn't appear to be supported in Internet Explorer, and some people use it incorrectly.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Although, on testing, it seems fine in IE6 as long as you don't use the commas.
Code:
clip: rect(5px 40px 45px 5px)
 
I loaded the test page from the article in IE7 and it worked as well.

-kaht

Looking for a puppy? [small](Silky Terriers are hypoallergenic dogs that make great indoor pets due to their lack of shedding and small size)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top