How to resize images on-the-fly?

无人久伴 提交于 2019-12-24 11:44:10

问题


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 is the object that contains the name of the image, it has 3 properties:

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

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.

For example:

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

htmlspecialchars($lineIMG->imagem_min)

will produce:

min_product002.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.

Any idea how this is accomplished

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?


回答1:


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 :-

Resizing the image in php for viewing purposes only

Resize image and display without saving it

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

http://phpthumb.sourceforge.net/



来源:https://stackoverflow.com/questions/20125291/how-to-resize-images-on-the-fly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!