tags:

views:

14

answers:

1

I am trying to save PhpThumb output. As what I could find on-line was not sufficient or to complex,I would like to ask if any one knows how to it?

$thumb_src="\"phpThumb/phpThumb.php?src=../apartmentsPhotos/".$num['ref']."/1.JPG&h=119&q=100\"";

echo" '<'img src=".$thumb_src />";

So what I want to do is to save the img src into an Image. (So far I was creating the thumbnails on the fly but it seems that google and my web server don´t like it to much.. Saving the thumbnails will insure that in no time I will have all my thumbnails in real files and then I will use this function just for new content.)

Thanks all.

A: 

Once you have generated the URL with this line you posted:

$thumb_src="\"phpThumb/phpThumb.php?src=../apartmentsPhotos/".$num['ref']."/1.JPG&h=119&q=100\"";

Pass it as a $_GET variable to another page, call it serveThumb.php:

if (!isset($_GET['img']))
      exit;

header('Content-type: application/pdf');
echo file_get_contents($_GET['img']);

You might have to add your own validation to serveThumb.php. Now you can save the result of serveThumb.php as a JPG.

Alternatively, save the contents of the image as a JPG file.

if (!isset($_GET['img']))
      exit;

$img = file_get_contents($_GET['img']);
file_put_contents("myImage.jpg", $img);
SimpleCoder
Cant I do it in the same page?Why is it needed to pass it to a different page?Thanks
ori
True, you can just save the contents of the URL in $thumb_src as an image.
SimpleCoder
Hi SimpleCoder!That´s what I am trying to do but don´t know how...Ori
ori