Reply
Cropping, not resizing an image
Old 05-05-2008, 10:23 AM Cropping, not resizing an image
Skilled Talker

Posts: 78
Name: David Howland
Location: New England
I'm pretty sure that this belongs in the HTML forum, although CSS might be the answer. I'm not sure. On the front page of my site, Frigid Light Photography I have an image which links to the newest photography album on the site. When i first coded the site I was dealing with a standard size image (scaled down to 520 px to fit the layout). I now want to use an image with different dimensions. Scaling the image to 520px wide produces an image which does not fit into the layout. Is there a way, with HTML or CSS to limit the vertical size of the image without resizing? I'd like to have it cropped off automatically, if possible. THanks!
davidhowland14 is offline
Reply With Quote
View Public Profile Visit davidhowland14's homepage!
 
Sponsored Links (We share ad revenue):
 
Old 05-05-2008, 10:52 AM Re: Cropping, not resizing an image
LadynRed's Avatar
Super Moderator

Posts: 5,623
Location: Tennessee
Quote:
Is there a way, with HTML or CSS to limit the vertical size of the image without resizing?
Well.. yes and no. You can't change the size of the image, but you can limit how much of it is displayed with CSS by setting overflow:none on the div the image is displayed in.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 05-05-2008, 11:36 AM Re: Cropping, not resizing an image
Skilled Talker

Posts: 78
Name: David Howland
Location: New England
is there a way to set the amount displayed in that particular <div> to a certain pixel value? I changed overflow to none and it just pushed my sidebar down to below the content. Here's the relavent code.

Code:
<div id="content">
		<h1>Latest Content</h1>
<a href="/gallery/main.php?g2_itemId=166"><img src="/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=178" width=520px></a>
</div>
and the CSS

Code:
#content {
float:left;
padding:20px;
width:520px;
overflow:none;
}
#content ol, #content ul {
margin-left:3em;
}
davidhowland14 is offline
Reply With Quote
View Public Profile Visit davidhowland14's homepage!
 
Old 05-05-2008, 12:30 PM Re: Cropping, not resizing an image
LadynRed's Avatar
Super Moderator

Posts: 5,623
Location: Tennessee
Well.. you could try the clip property:
http://www.w3schools.com/CSS/pr_pos_clip.asp
http://www.seifi.org/css/creating-th...-property.html

However, clipping works on an absolutely positioned element.

I'm sorry.. should be overflow:hidden .. my bad:
http://www.w3.org/TR/CSS21/visufx.html
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 05-05-2008, 01:43 PM Re: Cropping, not resizing an image
Webmaster Talker

Posts: 590
Location: Kokkola, Finland
crop part of the image that makes it look good at 520 wide in an image editor - if you have to crop it anyway then do it there rather than in the html/css.
davemies is offline
Reply With Quote
View Public Profile Visit davemies's homepage!
 
Old 05-05-2008, 02:18 PM Re: Cropping, not resizing an image
Skilled Talker

Posts: 78
Name: David Howland
Location: New England
yeah, i was hoping for a way to not have to create multiple copies of the image. obv i could copy it. ladynred, I tried the overflow property and no such luck.
davidhowland14 is offline
Reply With Quote
View Public Profile Visit davidhowland14's homepage!
 
Old 05-05-2008, 05:43 PM Re: Cropping, not resizing an image
angele803's Avatar
Perfectly Imperfect

Posts: 1,344
Name: Stephanie
Location: Oklahoma
Maybe something like this:
css:
Code:
#content {
float:left;
padding:20px;
width:520px;
overflow:none;
}
html:
Code:
<div id="content">
		<h1>Latest Content</h1>
        <div class="image">
			<a href="/gallery/main.php?g2_itemId=166"><img src="/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=178" width=520px></a>
		</div>
</div>
This is what ladynred suggested. I'm just elaborating.

You can set the height of that div to whatever you want. If the picture is taller than that specified height, it will be cropped off at the bottom.
angele803 is offline
Reply With Quote
View Public Profile
 
Old 05-05-2008, 06:54 PM Re: Cropping, not resizing an image
Skilled Talker

Posts: 78
Name: David Howland
Location: New England
tried this, it didn't work. thanks for your help, i just cropped a new image.
davidhowland14 is offline
Reply With Quote
View Public Profile Visit davidhowland14's homepage!
 
Old 05-05-2008, 09:45 PM Re: Cropping, not resizing an image
Novice Talker

Posts: 10
Name: redhat
I think that this situation may be resolved only by putting blank both sides or boh ends.
__________________
http://www.imhr.net
imhr is offline
Reply With Quote
View Public Profile Visit imhr's homepage!
 
Old 05-06-2008, 02:23 AM Re: Cropping, not resizing an image
Webmaster Talker

Posts: 590
Location: Kokkola, Finland
Quote:
Originally Posted by imhr View Post
I think that this situation may be resolved only by putting blank both sides or boh ends.
well no, not if you crop the image to fit those dimenions - which is what the OP did.
davemies is offline
Reply With Quote
View Public Profile Visit davemies's homepage!
 
Old 05-06-2008, 03:36 AM Re: Cropping, not resizing an image
chrishirst's Avatar
Super Moderator

Posts: 10,799
Location: Blackpool. UK
Sizing the container appropriately, then setting the image as a no-repeat background is also a method.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-06-2008, 04:35 AM Re: Cropping, not resizing an image
Webmaster Talker

Posts: 590
Location: Kokkola, Finland
but setting it as a background means that you don't have so much control over where it cuts off the image - at least, you're restricted to top, bottom, left, right, or trying to move it over by so many pixels

so much easier to just crop it in photoshop or whatever, rather than all these sledgehammer-to-crack-a-nut techniques
davemies is offline
Reply With Quote
View Public Profile Visit davemies's homepage!
 
Old 05-06-2008, 05:30 AM Re: Cropping, not resizing an image
chrishirst's Avatar
Super Moderator

Posts: 10,799
Location: Blackpool. UK
True, but it is an option to be considered given this;
Quote:
Is there a way, with HTML or CSS to limit the vertical size of the image without resizing
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Sponsored Links (We share ad revenue):
 
Reply     « Reply to Cropping, not resizing an image
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML


Page generated in 0.19126 seconds with 15 queries