2
votes

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

2
Your question is tagged with Java, PHP and .Net. Which do you want the solution to be tailored to?user212218
@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

2 Answers

2
votes

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/

0
votes

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 !