2

I want images to resize after upload in 4 different formats. If i resize it to best fit(i.e aspect ratio) some images come too small if height or width is too large than the other and if i resize it to fixed size then images get skewed. So what is the best way to resize a image. I am currently doing this using via imagemagik thumbnailImage() but i think it's a general problem. What are sites like google or facebook doing. what is the best thing to do in that case

stivlo
  • 83,644
  • 31
  • 142
  • 199
aWebDeveloper
  • 36,687
  • 39
  • 170
  • 242
  • Your question is tagged with Java, PHP and .Net. Which do you want the solution to be tailored to? –  Sep 27 '11 at 16:40
  • @Phoenix I'd say PHP because of the link, I remove the other tags because are misleading. I came here looking for a Java resize. – stivlo Oct 11 '11 at 07:25

2 Answers2

2

You can use resize functionality for resize image in different size during upload image. For example:

 include('SimpleImage.php');
  $image = new SimpleImage();
  $image->load($_FILES['uploaded_image']['tmp_name']);
  $image->resizeToWidth(300);
  $image->resizeToHeight(200);
  $image->save('resizeImage.jpg'

Similarly, you can save image in different size.

For more in detail you can find here:

http://sanjeevkumarjha.com.np/how-to-resize-and-crop-image/

Sanjeev Kumar Jha
  • 1,213
  • 2
  • 12
  • 20
0

You can also use ImageWorkshop: http://phpimageworkshop.com/doc/17/resizing.html

$layer = new ImageWorkshop(array("fileObject" => $_FILES["uploadedImage"]));
$layer->resizeInPixel(200, 150, true); // Conserve proportion !
$layer->save(__DIR__."/web/uploads/2012", "thumb.png", true, null, 95);

You will have a resized picture of 200px/150px with conserved proportion !

Sybio
  • 8,565
  • 3
  • 44
  • 53