doujie3888 2016-11-14 09:26
浏览 28
已采纳

生成缩略图与样式图像

I have an ecommerce site in which i have to display some products i.e 40-50 products per page.Every product has an image which displays the image of the product.

The main thing is that in the database i have a meduim/high quality image of the product whose dimensions would be around 720px-1024 px , these can vary and every image has dimensions in between these two.

Now, i have two different ways of displaying these images for product, i could use a php script to generate thumbnails from these pics whose dimensions would be 290X290 or i could use the style tag and set the width and height as 290X290 and source as the real image.

Let me explain this by an example.

Original Image

enter image description here

I could do this to display the image

  • <img src="/imagethumbnail.php?product_id=34"/>
  • <img style="height:290px;width:290px" src="productimg.png"/>

finall image

enter image description here

one calls a php script and generate a thumbnail image of size 290X290 while the other one simply uses the style tag.

Both of them are working fine but i think when i use the style tags i see a trade off in image quality.While when i use the script to generate the image i see a trade off in image generation like they take sometime to show up on the page.

What would be the better method to do this and what would be the perfect solution towards it?

  • 写回答

1条回答 默认 最新

  • dsriya5471 2016-11-14 09:38
    关注

    I think the standard method is to generate the thumbnails in advance. And you should probably set the width and height in the markup as attributes on the img element, rather than under the style attribute.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊