⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aspjpg.asp

📁 FlashPicViewer电子相册 v2.6 繁体中文版
💻 ASP
字号:
<%
''缩图函数 

'pathX   大图片路径比如"image/pic/"
'file    大图片文件名比如big.jpg
'Small   在图片前增加字符 比如设置为"Suo_"   输出的小图则是Suo_big.jpg

'w       宽锁定在这个数值内比如100
'h       高锁定在这个数值内比如100
'imgExt  廓张名   .jpg
'Write   是否覆盖   true覆盖缩小图  false不覆盖(检测有缩小图时候就不覆盖)
 
function CreateDIR(byval LocalPath) '建立目录的程序,如果有多级目录,则一级一级的创建
on error resume next
LocalPath = replace(LocalPath,"\","/")
set FileObject = server.createobject("Scripting.FileSystemObject")
patharr = split(LocalPath,"/")
path_level = ubound(patharr)
for i = 0 to path_level
  if i=0 then pathtmp=patharr(0) & "/" else pathtmp = pathtmp & patharr(i) & "/"
  cpath = left(pathtmp,len(pathtmp)-1)
  if not FileObject.FolderExists(cpath) then FileObject.CreateFolder cpath
next
set FileObject = nothing
if err.number<>0 then
  CreateDIR = false
  err.Clear
else
  CreateDIR = true
end if
end function

function makeimg(pathX,file,Small,w,h,imgExt,write)
if w<>""then 
w=int(w)
else
w=100
end if 
if h<>""then 
h=int(h)
else
h=100
end if 
filenamet=file
if Trim(filenamet)="" then 
exit function
end if 
    S_filenamet=Small
    FilePath=Server.MapPath(".")
    FilePath=FilePath & "/"&pathX &"/"  ''路径 
if (write="false") then 
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(FilePath &"/s/"& S_filenamet&filenamet))Then
Exit function
response.end 
else 
response.write("")
Set fso = nothing
''Exit function
end if 
end if

CreateDIR(FilePath &"/s/")


    Set Jpeg = Server.CreateObject("Persits.Jpeg")
    Jpeg.Open (FilePath & filenamet)

    '开始变更所有文件扩展名为jpg
    filenamelen=len(filenamet)
    filenamelen=filenamelen-4
    filenamet1=filenamet
    filenamet=left(filenamet,filenamelen)
    filenamet=filenamet&imgExt
    '结束文件名变更

    '开始判断哪边为长边,以长边进行缩放
    imgWidth=Jpeg.OriginalWidth
    imgHeight=Jpeg.OriginalHeight

    if imgWidth>=imgHeight and imgWidth>w then 
	Jpeg.Width=w
    Jpeg.Height=Jpeg.OriginalHeight/(Jpeg.OriginalWidth/w)
	end if
	
    if imgHeight>imgWidth and imgHeight>h then 
	Jpeg.Height=h
    Jpeg.Width=Jpeg.OriginalWidth/(Jpeg.OriginalHeight/h)
	end if
    '结束判断

	Jpeg.Sharpen 1, 130
    Jpeg.Save (FilePath &"/s/"& S_filenamet&filenamet)
	''response.write("ok")
	Jpeg.close()
	Set Jpeg = nothing
	end  function
		

	%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -