SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 8th, 2008, 12:38 AM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
Question How to clip images that don't fit?

Is there a method or code that can clip an image if it's too big?

This placeholder is the allowed size for images.
image placeholder: width = 150px, height = 150px

These images need to be clipped as apposed to resized to fit.
image1: width = 180px, height = 300px
image2: width = 320px, height = 712px

Is this possible?

Cheers

Reply With Quote
  #2  
Old March 10th, 2008, 06:29 PM
NetSurfer NetSurfer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 82 NetSurfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 16 h 33 m 9 sec
Reputation Power: 0
Well it depends on what's your aim. You can create a 150x150px div with background-image set to appropriate url. No matter how big is your image it will be clipped to the size of the div. You can also set background-position to 'center center' to place smaller images in the center or the div

Reply With Quote
  #3  
Old March 10th, 2008, 06:35 PM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
Cool,
What about dynamic images?
They will then also be clipped in the div.

Reply With Quote
  #4  
Old March 11th, 2008, 06:56 AM
NetSurfer NetSurfer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 82 NetSurfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 16 h 33 m 9 sec
Reputation Power: 0
Sure. You can also set overflow to 'auto' on the div to allow users to scroll images bigger than 150x150.

Reply With Quote
  #5  
Old March 11th, 2008, 07:15 AM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
Cool, Thanks

Rather not though.

Reply With Quote
  #6  
Old March 15th, 2008, 05:47 AM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
This doesn't cut off my images.
The image gets resized and looks crap, terrible!
Code:
.photos{
 float:right;
 padding: 10px;
 /*text-align: center;*/
}
.photos img{
 vertical-align: top;
 background-image: url(../images/image1.gif);/*true image size is 500px by 877px*/
 overflow: auto;
 width: 250px;
 background-position: center center;
 background-repeat: no-repeat;
 display: block;
}

Reply With Quote
  #7  
Old March 15th, 2008, 03:24 PM
NetSurfer NetSurfer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 82 NetSurfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 16 h 33 m 9 sec
Reputation Power: 0
I was talking about DIV not IMG. For example, this style when applied to a DIV should work as i told:
Code:
div {
 width:150px;
 height:150px
 background-image: url(../images/image1.gif);/*true image size is 500px by 877px*/
 background-position: center center;
 background-repeat: no-repeat;
}

If you want to add scrolling you may use this:
Code:
<style>
div {float:left;width:150px;height:150px;border:1px solid red;overflow:auto}
</style>
</head>
<body>
<div><img src='/test/big_image.png' /></div>
</body>

Reply With Quote
  #8  
Old March 15th, 2008, 03:29 PM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
Cool thanks.
I got it working, like right now (talk about coinsedince(no idea how to spell this f'n thing))

Reply With Quote
  #9  
Old March 15th, 2008, 03:36 PM
NetSurfer NetSurfer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 82 NetSurfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 16 h 33 m 9 sec
Reputation Power: 0
Both centering small images and scrolling big ones figured out to be a bit more intricate. In this code DIV adds scrolling and TD adds centering vertically ('caz it's the only element that allows this - in DIV you can align subelements only relative to text baseline, not to its bounds - see CSS spec).
Code:
<style>
div {width:150px;height:150px;overflow:auto;border:1px   solid red}
table {border-collapse:collapse}
td {padding:0px;width:150px;height:150px;text-align:center;vertical-align:middle}
</style>
</head>
<body>
<div>
 <table>
 <tr>
  <td><img src='/test/big_image.png' /></td>
 </tr>
 </table>
</div>
<div>
 <table>
 <tr>
  <td><img src='/test/small_image.png' /></td>
 </tr>
 </table>
</div>
</body>

Reply With Quote
  #10  
Old March 15th, 2008, 03:43 PM
student101 student101 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 98 student101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 27 m 47 sec
Reputation Power: 1
Interesting...
I will have a look at it tomorrow morning when I am more awake.

Thank you,
You know your CSS

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > How to clip images that don't fit?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway