捣碎图像,最佳做法?(Crunching images, best practices?)

编程入门 行业动态 更新时间:2024-10-21 20:26:57
捣碎图像,最佳做法?(Crunching images, best practices?)

我已经为我的应用程序中的一个东西的图像上传编写了图像处理。

我的应用程序将图像的原始副本保存到服务器,并在数据库中放置一个带有文件名和扩展名的条目。 (还有其他信息)。

在此之后,我将5个版本的图像(各种分辨率)保存到服务器,但我没有为这些添加数据库条目:

例如:

uploaddir + filename + "-1024" + extension uploaddir + filename + "-800" + extension uploaddir + filename + "-640" + extension uploaddir + filename + "-320" + extension uploaddir + filename + "-thumbnail" + extension

所以这意味着我可以使用特定尺寸的图像(例如):

@Settings.UploadURL@fieldImage.File.UniqueName@ImageSizes.Thumbnail@fieldImage.File.Extension;

听起来不错吗? 或者你认为我还应该针对所有图像尺寸创建数据库条目?

所以澄清一下:

我保存了一个具有唯一文件名和扩展名的数据库条目 我保存到服务器,各种不同的图像大小,其大小作为文件名的一部分添加 我有一个常量类,所以我可以添加它只显示我想要的大小的网址

通过采用这种方法,您可以预见到将来会遇到哪些问题?

I have written the image crunching for the image upload of a thing in my application.

My application saves the original copy of the image to the server, and places an entry in the database with a file name and extension. (with other info too).

After this, I save 5 versions of the image (various resolutions) to the server but I do not put database entries in for these:

For example:

uploaddir + filename + "-1024" + extension uploaddir + filename + "-800" + extension uploaddir + filename + "-640" + extension uploaddir + filename + "-320" + extension uploaddir + filename + "-thumbnail" + extension

So this means i can use specific sizes of the image (for example):

@Settings.UploadURL@fieldImage.File.UniqueName@ImageSizes.Thumbnail@fieldImage.File.Extension;

Does this sound okay? Or do you think I should also create database entries against all image sizes?

So to clarify:

I save one database entry that has a unique file name and the extension I save to the server, various different image sizes with the size added as part of the file name I have a class with constants in so that i can add that to only show the url of the size i want

What issues can you foresee me having in the future by taking this approach?

最满意答案

保留条目可能是值得的。 如果没有别的,您可以稍后决定,如果原始图像质量太低,您希望逻辑创建不同大小的图像。

假设你得到一张320像素的照片......你真的想尝试升级吗?

It might be worth keeping entries. If nothing else, you can decide later that you want logic to not create the different sized images if the original already is too low of quality.

Say you get a 320 px image... Do you really want to try and upscale that?

更多推荐

本文发布于:2023-04-29 02:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334541.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   做法   Crunching   images   practices

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!