0

I came across few solutions but all those were based on uploading an image. What I want is that it should fetch the image from one folder, resize it of particular size and then save it in other folder.

Guns
  • 2,598
  • 2
  • 19
  • 49
sabin
  • 615
  • 9
  • 14
  • 1
    Instead of asking us to give code, Google it first, then try it, _then_ ask us a constructive question if it doesn't work. – PurkkaKoodari Apr 16 '14 at 06:45

2 Answers2

0

Try PHP library function imagecopyresized()

Here is a sample programme,

// File and new size
$filename = 'test.jpg';
$percent = 0.5;

// Content type
header('Content-Type: image/jpeg');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);

// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

// Output
imagejpeg($thumb);

Here is the manual for imagecopyresized(). http://www.php.net/manual/en/function.imagecopyresized.php

dipak_pusti
  • 1,399
  • 2
  • 19
  • 37
0

I normally use the GD library for this. It works fine. For an example, please see this url: http://runnable.com/UnF-tFdudNt1AABt/how-to-resize-an-image-using-gd-library-for-php

Rogier Lommers
  • 1,787
  • 3
  • 16
  • 32