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 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多