制作百万美元主页动态图像网格的最佳方法?
我一直在考虑为一个小型的家庭爱好想法设置一个类似于 milliondollarhomepage 的图像网格,它会是动态的。网格大小约为 500x500,我想知道编写此代码的最佳方法,它不能慢。
我认为它会像这样工作:
- 用户选择他们在网格上的位置并上传他们的图像。
- 图像存储在数据库中的图像类型列中
- 在将页面呈现给公众时,
.NET
循环遍历从数据库上传的所有图像,并根据每个数据库行数据动态创建图像;广场上的存储位置
问题是我不确定这是否是一个愚蠢的方法?
你们觉得怎么样?
谢谢!
I've been thinking about setting up a image grid similar to milliondollarhomepage for a small domestic hobby idea , it would be dynamic. The grid would be around 500x500, I am wondering the best way to code this up, It can't be slow.
I am thinking it will work like this:
- Users choose their place on the grid and upload their image.
- The image is stored in the DB in a image type column
- On rendering the page to the public,
.NET
cycles through all the uploaded images from the DB and dynamically creates the image based on each DB rows data & stored place in the square
The thing is I am not sure if this is a silly way to do it?
What do you guys think?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当有人上传更改时,您最好重新创建图像。假设访问者的数量远远多于贡献者,那么为每个请求重新创建图像将是一种浪费。
You're better off just recreating the image whenever somebody uploads a change. Assuming there will be far more visitors than contributors it would be wasteful to recreate the image for every request.
你的方法对我来说听起来很合理。
正如戈迪所说;您可能不想在每次访问时重新生成图像 - 但生成图像并将其保存到文件系统的代码无论如何都会大致相同。然后,您可以使用大型 HTML 地图来定义单个广告的“区域”。这将使您在单击时拥有不同的鼠标悬停文本和 URL。
同样,每当有新客户端出现时,我都会很想生成 HTML 文件。我的意思是,更新数据库并使用 .NET 代码生成 HTML。但是带有静态图像的静态 html 页面将比动态构建任何内容的性能要高得多。
Your approach sounds pretty reasonable to me.
Like Gordy said; you probably don't want to regenerate the image on each visit - but your code to generate the image and save it to the file system would be largely the same anyway. Then, you can use a large HTML Map to define the individual ad's 'area'. That will let you have different mouse-over text and URL when clicked.
Again, I'd be tempted to just generate the HTML file whenever you have a new client come on. I mean, update your database and use .NET code to generate the HTML. But the static html page with a static image is going to be a lot more performant than building anything dynamically.