导航:首页 > 文件处理 > asp网页压缩

asp网页压缩

发布时间:2024-05-01 07:39:22

Ⅰ asp 实现图片上传的时候压缩

按比例压缩图片:

SmallImgFilet = "SmallImg-"&smallname&".jpg" '小图片指定取名

If IsEmpty(SmallImgFile) then

'dim L as Single , H as Single

Set Jpeg = Server.CreateObject("Persits.Jpeg") '调用组件

Path = Server.MapPath("../") & "\" & BigImgFile '待缩小图片路径 放在根目录 你可以制定文件夹 在../后面
Jpeg.Open Path '打开图片
L = 120/80'缩略图高与宽比 你如果只限制宽度就不用下面else的高度比例判断 只按宽度的对应大图比例缩小就可以了

H= jpeg.OriginalWidth/jpeg.OriginalHeight

If H > L Then
jpeg.Width = 120
jpeg.Height = (jpeg.OriginalHeight*120)/jpeg.OriginalWidth
Else
jpeg.Height = 80
jpeg.Width = (jpeg.OriginalWidth*80)/jpeg.OriginalHeight
End If
'保存图片
Jpeg.Save Server.MapPath("../") & "\"&SmallImgFilet'&".jpg"
set Jpeg=nothing
end if

Ⅱ win rar 通过asp。net调用压缩 如何指定压缩成zip格式

打开WinRAR主窗口,然后单击菜单“选项→设置”,在“设置”窗口中选择“压缩”选项卡,再单击“创建默认配置”,在打开的窗口中选择“压缩文件格式”为“RAR”,最后“确定”保存设置即可。

Ⅲ asp图片上传压缩小,现在的上传方法上传的都是原图,太大了,访问速度太慢

给你一个过程你看下
<%
dim arr(3)
dim upload,file,formName,formPath,iCount,filename,fileExt,i
set upload=new upload_5xSoft ''建立上传对象

formPath="../upImgFile/" '图片存放的路径:proct目录下的uploadimages文件夹 ''在目录后加(/)

''列出所有上传了的文件
for each formName in upload.file
set file=upload.file(formName)
if file.filesize>0 then
if file.filesize>10000000 then
response.write "<font size=2>图片大小超小了限制[<a href=# onclick=history.go(-1)>重新上传</a>]</font>"
response.end
end if
fileExt=lcase(right(file.filename,4))
if fileExt<>".jpg" then
response.write "<font size=2>文件格式限制[<a href=# onclick=history.go(-1)>请重新上传</a>]</font>"
response.end
end if
end if

filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&file.FileName

if file.FileSize>0 then ''如果 FileSize > 0 说明有文件数据
file.SaveAs Server.mappath(formpath&filename) ''保存文件

' 图片位置
dim PhotoPath
PhotoPath = Server.MapPath(formpath&filename)
'缩小大图
call OKbigpic(PhotoPath)

'response.write file.FilePath&file.FileName&"("&file.FileSize&") => "&formPath&File.FileName&"上传成功<br>"
response.write "上传成功 <a href=# onclick=history.go(-1)>请返回</a>"

end if
set file=nothing
next
set upload=nothing
Response.Write "<script>parent.add.P_url.value='"&FileName&"'</script>"

sub OKbigpic(FileName)
Dim bigpic,bigpicPath,fss
Set bigpic = Server.CreateObject("Persits.Jpeg")
set fss=createobject("scripting.filesystemobject")
' 设置图片质量
bigpic.Interpolation=2
bigpic.Quality=90
' 图片位置
if fss.fileExists(FileName) then
bigpic.Open FileName

'下面是按比例缩放
n_MaxWidth=900
n_MaxHeight=1500

'按比例取得缩略图宽度和高度
Dim n_OriginalWidth, n_OriginalHeight '原图片宽度、高度
Dim n_BuildWidth, n_BuildHeight '缩略图宽度、高度
Dim div1, div2
Dim n1, n2
'修改Jpeg
n_OriginalWidth = bigpic.Width
n_OriginalHeight = bigpic.Height
div1 = n_OriginalWidth / n_OriginalHeight
div2 = n_OriginalHeight / n_OriginalWidth
n1 = 0
n2 = 0
If n_OriginalWidth > n_MaxWidth Then
n1 = n_OriginalWidth / n_MaxWidth
Else
n_BuildWidth = n_OriginalWidth
End If
If n_OriginalHeight > n_MaxHeight Then
n2 = n_OriginalHeight / n_MaxHeight
Else
n_BuildHeight = n_OriginalHeight
End If
If n1 <> 0 Or n2 <> 0 Then
If n1 > n2 Then
n_BuildWidth = n_MaxWidth
n_BuildHeight = n_MaxWidth * div2
Else
n_BuildWidth = n_MaxHeight * div1
n_BuildHeight = n_MaxHeight
End If
End If

'指定宽度和高度生成
bigpic.Width = n_BuildWidth
bigpic.Height = n_BuildHeight

' 保存文件
bigpic.Save (FileName)
' 注销对象
Set bigpic = Nothing

end if
end sub
%>

Ⅳ 关于ASP自动解压缩 压缩文件的问题

1、 是不是什么文件都可以压缩?
答:压缩是可以,但有些可执行文件解压后并不能运行。

可执行程序文件或软件安装文件可以压缩吗?还是必须放进文件夹里才能压缩?
答:可执行程序文件可以直接压缩。
软件安装文件必须放进文件夹里压缩,否则解压后程序不能正常运行。

2、 一般的压缩比例是多少?什么的文件压缩比例小?小到什么程度?
答:你用WinRAR软件,有压缩比例测试,一目了然。

3、 如何制作含有解压密码的压缩文件?
答:打开winrar,选择你要压缩的文件,点工具栏上的添加-选择“高级”选项-设置密码。

4、 如何破解不知道密码的压缩文件?
答:Advanced ZIP Password Recovery 3.52可以解开ZIP压缩文件的密码;
Advanced RAR Password Recovery 1.10可以解开RAR压缩文件的密码。

5、 除了winrar和winzip外还有哪些常用的压缩解压工具?
答:winace

Ⅳ 求asp.net 图片上传压缩图片大小代码 就是减小图片的分辨率存储图片到服务器

c#生成图片缩略图的类
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

/// <summary>
/// 图片处理类
/// 1、生成缩略图片或按照比例改变图片的大小和画质
/// 2、将生成的缩略图放到指定的目录下
/// </summary>
public class ImageClass
{
public Image ResourceImage;
private int ImageWidth;
private int ImageHeight;

public string ErrMessage;

/// <summary>
/// 类的构造函数
/// </summary>
/// <param name="ImageFileName">图片文件的全路径名称</param>
public ImageClass(string ImageFileName)
{
ResourceImage=Image.FromFile(ImageFileName);
ErrMessage="";
}

public bool ThumbnailCallback()
{
return false;
}

/// <summary>
/// 生成缩略图重载方法1,返回缩略图的Image对象
/// </summary>
/// <param name="Width">缩略图的宽度</param>
/// <param name="Height">缩略图的高度</param>
/// <returns>缩略图的Image对象</returns>
public Image GetRecedImage(int Width,int Height)
{
try
{
Image RecedImage;

Image.GetThumbnailImageAbort callb=new Image.GetThumbnailImageAbort(ThumbnailCallback);

RecedImage=ResourceImage.GetThumbnailImage(Width,Height,callb,IntPtr.Zero);

return RecedImage;
}
catch(Exception e)
{
ErrMessage=e.Message;
return null;
}
}

/// <summary>
/// 生成缩略图重载方法2,将缩略图文件保存到指定的路径
/// </summary>
/// <param name="Width">缩略图的宽度</param>
/// <param name="Height">缩略图的高度</param>
/// <param name="targetFilePath">缩略图保存的全文件名,(带路径),参数格式:D:Images ilename.jpg</param>
/// <returns>成功返回true,否则返回false</returns>
public bool GetRecedImage(int Width,int Height,string targetFilePath)
{
try
{
Image RecedImage;

Image.GetThumbnailImageAbort callb=new Image.GetThumbnailImageAbort(ThumbnailCallback);

RecedImage=ResourceImage.GetThumbnailImage(Width,Height,callb,IntPtr.Zero);
RecedImage.Save(@targetFilePath,ImageFormat.Jpeg);

RecedImage.Dispose();

return true;
}
catch(Exception e)
{
ErrMessage=e.Message;
return false;
}
}

/// <summary>
/// 生成缩略图重载方法3,返回缩略图的Image对象
/// </summary>
/// <param name="Percent">缩略图的宽度百分比 如:需要百分之80,就填0.8</param>
/// <returns>缩略图的Image对象</returns>
public Image GetRecedImage(double Percent)
{
try
{
Image RecedImage;

Image.GetThumbnailImageAbort callb=new Image.GetThumbnailImageAbort(ThumbnailCallback);

ImageWidth=Convert.ToInt32(ResourceImage.Width*Percent);
ImageHeight=Convert.ToInt32(ResourceImage.Width*Percent);

RecedImage=ResourceImage.GetThumbnailImage(ImageWidth,ImageHeight,callb,IntPtr.Zero);

return RecedImage;
}
catch(Exception e)
{
ErrMessage=e.Message;
return null;
}
}

/// <summary>
/// 生成缩略图重载方法4,返回缩略图的Image对象
/// </summary>
/// <param name="Percent">缩略图的宽度百分比 如:需要百分之80,就填0.8</param>
/// <param name="targetFilePath">缩略图保存的全文件名,(带路径),参数格式:D:Images ilename.jpg</param>
/// <returns>成功返回true,否则返回false</returns>
public bool GetRecedImage(double Percent,string targetFilePath)
{
try
{
Image RecedImage;

Image.GetThumbnailImageAbort callb=new Image.GetThumbnailImageAbort(ThumbnailCallback);

ImageWidth=Convert.ToInt32(ResourceImage.Width*Percent);
ImageHeight=Convert.ToInt32(ResourceImage.Width*Percent);

RecedImage=ResourceImage.GetThumbnailImage(ImageWidth,ImageHeight,callb,IntPtr.Zero);

RecedImage.Save(@targetFilePath,ImageFormat.Jpeg);

RecedImage.Dispose();

return true;
}
catch(Exception e)
{
ErrMessage=e.Message;
return false;
}
}

}
本篇文章来源于:开发学院 http://e.codepub.com 原文链接:http://e.codepub.com/2011/0118/28884.php

Ⅵ asp.net 将原图用代码自动压缩成规定大小后上传

上传时候判断原图片大小

然后根据大小判断

  System.Drawing.Image originalImage = System.Drawing.Image.FromStream(file.InputStream);
if (originalImage.Width > 800 || originalImage.Height > 800)

然后规定大小

这问题主要地方是如何获取图片的原大小,只要能获取原大小就能规定格式

阅读全文

与asp网页压缩相关的资料

热点内容
18辍学做程序员 浏览:873
高一对数的运算法则及公式 浏览:498
压缩二分之一以上做骨水泥手术 浏览:360
服务器怎么让文件可以下载地址 浏览:190
加密货币2021年市值 浏览:840
安卓19怎么玩侠盗飞车 浏览:137
农业经济学pdf 浏览:723
有什么分享软件的app 浏览:43
电脑文件加密的文件怎么找出来 浏览:89
Java实现sha 浏览:527
购物车java代码 浏览:316
windows多核编程 浏览:609
股旁网选股指标公式源码 浏览:856
python运维管理工具 浏览:456
功率分配算法 浏览:491
钱豆豆app可以做什么 浏览:194
腾讯云服务器还需要数据库吗 浏览:767
比较器编程 浏览:738
苹果赏金赛和平精英是什么app 浏览:986
idea查找项目所在文件夹 浏览:163