如何动态调整图像大小? [英] How to resize images on-the-fly?

查看:181
本文介绍了如何动态调整图像大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚从共享托管服务收到一个旧的php网站,我需要迁移到新的数据中心。我遇到了这个:

I just receive a old php site from a shared hosting service, that i need to migrate to a new data center.I came across this:

有一个图像调整动态机制,在浏览器中更改图像名称会改变其大小:

there is a image resize on-the-fly mechanics, changing the name of the image in the browser changes his size:

if(mysql_num_rows($resultIMG)>0) {
  $lineIMG = mysql_fetch_object($resultIMG);
  echo "<img src=\"../Dev/modules/dGC/images/".htmlspecialchars($lineIMG->imagem_min)."\" alt=\"\" title=\"\">&nbsp;";
}

$ lineIMG是包含图像名称的对象,它有3个属性:

$lineIMG is the object that contains the name of the image, it has 3 properties:

$lineIMG->image;
$lineIMG->image_min;
$lineIMG->image_med;

只有$ lineIMG->图像包含图像的真实名称,另一个前面有一个前缀对应于我们想要调整大小的大小。

Only the $lineIMG->image contains the real name of the image, the other have a prefix before corresponding to the size that we want to resize.

例如:

如果图像名为product002。 jpg,此功能:

if the image is called product002.jpg, this function:

htmlspecialchars($lineIMG->imagem_min)

将产生:

min_product002.jpg

如果我将浏览器中的名称更改为med_product002.jpg,那么作为回应会给我中等大小的图像。文件系统中没有文件min_product002.jpg或med_product002.jpg,只有原始产品002.jpg。

and if I change the name in the browser to med_product002.jpg, that in response will give me the medium size image. None of the files min_product002.jpg or med_product002.jpg exists in the file system, only the original product002.jpg.

知道如何实现这一目标

我找到了这篇帖子,解释了如何通过使用mod-rewrite来实现这一点,这可以是我网站中使用的机制吗?

I found this post, explaining how to achieve this by using the mod-rewrite, can this be the mechanics used in my site?

但是我的页面中没有包含脚本,这可能是全局的,因为它共享主机?

But no script is inclued in my pages, can this be global, since it a shared hosting?

推荐答案

我还有一些参考资料。我使用过早期的 phpthumb 库。它根据原始图像大小和模式(横向或纵向)调整图像大小。

I have some more references. I have used earlier phpthumb library. it resize image on the basis of original image size and mode(landscape or portrait).

以下是一些参考资料: -

Here are some more reference :-

在php中调整图像大小仅供查看

调整图像大小并显示而不保存

http://joedesigns.com/v22/ ?page = scripts_widgets& id = 67

http://phpthumb.sourceforge.net/

这篇关于如何动态调整图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆