如何将图像大小限制为AxB?
我需要显示图片,但只有AxB一样大。如果它小于
AxB,那么我将以原始大小显示它,如果它大于AxB,
我会调整它的大小。
但是,如果尺寸为100x200,但我将其限制为50x60,那么如果我使用
height x width,则图像显示效果不佳。所以,我希望它的原始尺寸与原来的尺寸相比,所以它将从100x200到30x60。
我该怎么办呢如果它托管在我的服务器上, - 任何服务器端图像
程序改变大小?
如果托管远程,我怎么能这样做,我只使用src热门链接, -
所以我必须找到一种方法在Javascript中调整大小。
I need to display pictures, but only as large as AxB. If it is smaller than
AxB, then I will display it in the original size, if it is larger than AxB,
I will resize it.
However, if the size is 100x200, but I limited it to 50x60, then if I use
height x width, the image does not display well. So, I want it to srink is a
ratio of the original size, so it is will be from 100x200 to 30x60.
How can I do it if it is hosted on my server, -- Any server side image
program to change sizes?
How can I do it if it is hosted remoted, and I only use the src hot link, --
so I must find a way to do it in Javascript to resize it.
http://links.i6networks.com 写道:
你是他妈的无礼。
-
Charles Sweeney
http://CharlesSweeney.com
http://links.i6networks.com wrote:
You are a fucking nuiscance.
--
Charles Sweeney
http://CharlesSweeney.com
Charles Sweeney写道:
Charles Sweeney wrote:
http:// links.i6networks.com 写道:
你ar他妈的无礼。
你是如何确定甜点的? (:P)
- Charles Sweeney
http:// CharlesSweeney。 com
-
X-No-Archive:是
--
X-No-Archive: Yes
http://links.i6networks.com 于2004年8月16日在
comp.lang.javascript :
http://links.i6networks.com wrote on 16 aug 2004 in
comp.lang.javascript:
我需要显示图片,但只有AxB一样大。如果它比AxB小,那么我会以原始尺寸显示它,如果它比AxB大,我会调整它的尺寸。
但是,如果尺寸是100x200,但我限制为50x60,然后如果我使用高度x宽度,图像显示不好。所以,我希望它的收缩率是原始尺寸的比例,因此它将从100x200
到30x60。
如果它是托管我怎么能这样做在我的服务器上, - 任何服务器端图像
程序改变大小?
取决于你的服务器端平台,在ASP下你需要一个com
对象我想。 OT在这里。
如果托管远程我怎么能这样做,我只使用src hot
链接, - 所以我必须找到一种方法在Javascript中调整大小它。
I need to display pictures, but only as large as AxB. If it is smaller
than AxB, then I will display it in the original size, if it is larger
than AxB, I will resize it.
However, if the size is 100x200, but I limited it to 50x60, then if I
use height x width, the image does not display well. So, I want it to
srink is a ratio of the original size, so it is will be from 100x200
to 30x60.
How can I do it if it is hosted on my server, -- Any server side image
program to change sizes?
Depends on your serverside platform, under ASP you would need a com
object I suppose. OT here.
How can I do it if it is hosted remoted, and I only use the src hot
link, -- so I must find a way to do it in Javascript to resize it.
只测试了IE:
< img id =" pp" src =" my.gif">
< script>
p = document.getElementById(" pp")
w = p.clientWidth
h = p.clientHeight
//最大50x60
if(w> 50 || h> 60){
if(w / h> 50/60){
p.style.width =''50px''
alert("宽度校正,相对方面保持)
}否则{
p.style.height ='''60px''
alert("高度纠正,相对方面保持)
}
}否则{
警报(不纠正,足够小)
}
< / script>
-
Evertjan。
荷兰。
(请将我的电子邮件地址中的x'变为点数)
Only IE tested:
<img id="pp" src="my.gif">
<script>
p = document.getElementById("pp")
w = p.clientWidth
h = p.clientHeight
// max 50x60
if (w>50||h>60){
if (w/h>50/60){
p.style.width=''50px''
alert("width corrected, relative aspect kept")
} else {
p.style.height=''60px''
alert("height corrected, relative aspect kept")
}
} else {
alert("no correction, is small enough")
}
</script>
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)