1

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?

doflip
  • 23
  • 1
  • 4
  • Yes. Basically you have to detect when user want to open image - if image exists then user will open it as normal image, if not then he is redirected to script which reads what image user wanted to open and then create it, save in folder (so next time someone ask for this image it will get already prepared one) and then serve it to user. Instead of high/med/low you can use names like 200x300 so if you need other size you can just write and it will work without any additional work. – Volvox Nov 21 '13 at 15:48
  • there are no resized images after the resize, so it does not save any new image in the file system. – doflip Nov 21 '13 at 16:08

1 Answers1

0

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/

Community
  • 1
  • 1
Roopendra
  • 7,674
  • 16
  • 65
  • 92
  • I edit the question, since no script is inclued in my pages, is there a way of doing this without php functions 'imagecopyresampled'? – doflip Nov 21 '13 at 16:11
  • @doflip actually I dont know if any solution is there without php function. But as I found some link related to your question and I used `phpthumb` library so I thought share with you. – Roopendra Nov 21 '13 at 16:18