See if you like the image resizing quality of this open source ASP.NET module. There's a live demo, so you can mess around with it yourself. It yields results that are (to me) impossible to distinguish from Photoshop output. It also has similar file sizes - MS did a good job on their JPEG encoder.
为了涵盖所有基础,如果您真的只是指图像的文件大小而不是实际的图像尺寸,我建议您查看图像数据的无损编码。 我对此的建议是将图像重新保存为 .png 文件(我倾向于使用 Paint 作为 Windows 中图像的免费转码器。在 Paint 中加载图像,另存为新格式)
Unless you resize up, you cannot do this with raster graphics.
What you can do with good filtering and smoothing is to resize without losing any noticable quality.
You can also alter the DPI metadata of the image (assuming it has some) which will keep exactly the same pixel count, but will alter how image editors think of it in 'real-world' measurements.
And just to cover all bases, if you really meant just the file size of the image and not the actual image dimensions, I suggest you look at a lossless encoding of the image data. My suggestion for this would be to resave the image as a .png file (I tend to use paint as a free transcoder for images in windows. Load image in paint, save as in the new format)
I believe what you're looking to do is "Resize/Resample" your images. Here is a good site that gives instructions and provides a utility class(That I also happen to use):
Are you resizing larger, or smaller? By a small % or by a larger factor like 2x, 3x? What do you mean by quality for your application? And what type of images - photographs, hard-edged line drawings, or what? Writing your own low-level pixel grinding code or trying to do it as much as possible with existing libraries (.net or whatever)?
There is a large body of knowledge on this topic. The key concept is interpolation.
发布评论
评论(11)
您无法在不损失某些质量的情况下调整图像大小,因为您减少了像素数量。
不要减小客户端的大小,因为浏览器不能很好地调整图像大小。
您可以做的是在渲染之前或在用户上传时以编程方式更改大小。
这是一篇文章,解释了在 C# 中执行此操作的一种方法:
http://www.codeproject.com/KB/GDI-plus/imageresize。 ASPX
You can't resize an image without losing some quality, simply because you are reducing the number of pixels.
Don't reduce the size client side, because browsers don't do a good job of resizing images.
What you can do is programatically change the size before you render it, or as a user uploads it.
Here is an article that explains one way to do this in c#:
http://www.codeproject.com/KB/GDI-plus/imageresize.aspx
看看您是否喜欢这个开源 ASP.NET 模块的图像大小调整质量。 有一个现场演示,所以你可以自己尝试一下。 它产生的结果(对我来说)无法与 Photoshop 输出区分开来。 它也有类似的文件大小 - MS 在他们的 JPEG 编码器上做得很好。
See if you like the image resizing quality of this open source ASP.NET module. There's a live demo, so you can mess around with it yourself. It yields results that are (to me) impossible to distinguish from Photoshop output. It also has similar file sizes - MS did a good job on their JPEG encoder.
除非调整大小,否则无法使用光栅图形执行此操作。
通过良好的过滤和平滑,您可以在不损失任何明显质量的情况下调整大小。
您还可以更改图像的 DPI 元数据(假设它有一些),这将保持完全相同的像素数,但会改变图像编辑器在“真实世界”测量中对它的看法。
为了涵盖所有基础,如果您真的只是指图像的文件大小而不是实际的图像尺寸,我建议您查看图像数据的无损编码。 我对此的建议是将图像重新保存为 .png 文件(我倾向于使用 Paint 作为 Windows 中图像的免费转码器。在 Paint 中加载图像,另存为新格式)
Unless you resize up, you cannot do this with raster graphics.
What you can do with good filtering and smoothing is to resize without losing any noticable quality.
You can also alter the DPI metadata of the image (assuming it has some) which will keep exactly the same pixel count, but will alter how image editors think of it in 'real-world' measurements.
And just to cover all bases, if you really meant just the file size of the image and not the actual image dimensions, I suggest you look at a lossless encoding of the image data. My suggestion for this would be to resave the image as a .png file (I tend to use paint as a free transcoder for images in windows. Load image in paint, save as in the new format)
我相信您想要做的是“调整大小/重新采样”您的图像。 这是一个很好的网站,提供说明并提供实用程序类(我也碰巧使用):
http://www.codeproject.com/KB/GDI-plus/imgresizoutperfgdiplus.aspx
I believe what you're looking to do is "Resize/Resample" your images. Here is a good site that gives instructions and provides a utility class(That I also happen to use):
http://www.codeproject.com/KB/GDI-plus/imgresizoutperfgdiplus.aspx
在这里您还可以在此类中找到添加水印代码:
Here you can find also add watermark codes in this class :
有一些东西,上下文感知调整大小,不知道你是否能够使用它,但它值得一看,那是肯定的
一个不错的视频演示(放大出现在中间)
http://www.youtube.com/watch?v=vIFCV2spKtg
这里可以是一些代码。
http://www.semanticmetadata.net /2007/08/30/content-aware-image-resizing-gpl-implementation/
这是否太过分了? 也许有一些简单的滤镜可以应用于放大的图像来稍微模糊像素,你可以研究一下。
There is something out there, context aware resizing, don't know if you will be able to use it, but it's worth looking at, that's for sure
A nice video demo (Enlarging appears towards the middle)
http://www.youtube.com/watch?v=vIFCV2spKtg
Here there could be some code.
http://www.semanticmetadata.net/2007/08/30/content-aware-image-resizing-gpl-implementation/
Was that overkill? Maybe there are some easy filters you can apply to an enlarged image to blur the pixels a bit, you could look into that.
您的尺寸是变大了还是变小了? 是小百分比还是更大的系数,如 2 倍、3 倍? 您的应用程序的质量是什么意思? 什么类型的图像——照片、硬边线条图,还是什么? 编写自己的低级像素研磨代码或尝试尽可能使用现有库(.net 或其他库)来完成它?
关于这个主题有大量的知识。 关键概念是插值。
浏览建议:
* http://www.all-in-one.ee/ ~dersch/interpolator/interpolator.html
* http://www.cambridgeincolour.com/tutorials/image-interpolation.htm
* 对于 C#:https://secure.codeproject.com/KB/GDI-plus/imageprocessing4.aspx?display=PrintAll&fid=3657& df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26&select=629945
* 这是特定于 java 的,但可能具有教育意义 - http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
Are you resizing larger, or smaller? By a small % or by a larger factor like 2x, 3x? What do you mean by quality for your application? And what type of images - photographs, hard-edged line drawings, or what? Writing your own low-level pixel grinding code or trying to do it as much as possible with existing libraries (.net or whatever)?
There is a large body of knowledge on this topic. The key concept is interpolation.
Browsing recommendations:
* http://www.all-in-one.ee/~dersch/interpolator/interpolator.html
* http://www.cambridgeincolour.com/tutorials/image-interpolation.htm
* for C#: https://secure.codeproject.com/KB/GDI-plus/imageprocessing4.aspx?display=PrintAll&fid=3657&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=26&select=629945
* this is java-specific but might be educational - http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
这是一个 论坛帖子,提供了 C# 图像调整大小代码示例。 您可以使用 GD 库 绑定器之一在 C# 中进行重采样。
Here is a forum thread that provides a C# image resizing code sample. You could use one of the GD library binders to do resampling in C#.
除非您正在制作矢量图形,否则无法在不损失某些图像质量的情况下调整图像大小。
Unless you're doing vector graphics, there's no way to resize an image without potentially losing some image quality.
正如 rcar 所说,你不能不损失一些质量,在 C# 中你能做的最好的事情是:
As rcar says, you can't without losing some quality, the best you can do in c# is:
来自此处
from here