Sure.
If you have GD installed on your server you can use http://php.net/manual/en/book.image.php
If you have imagemagick you can use http://php.net/manual/en/book.imagick.php
Here is a quick example using GD. This assumes you're uploading the image using an <input type="file" name="FileUploadName">
element.
$uploadedFilePath = $_FILES["FileUploadName"]["tmp_name"];
$somePermanentPath = "/tmp/mynewfile";
move_uploaded_file($uploadedFilePath, $somePermanentPath);
$srcImg = imagecreatefromstring(file_get_contents($somePermanentPath));
$srcW = imagesx($srcImg);
$srcH = imagesy($srcImg);
if ($srcW > $srcH)
{
$widthFactor = 1;
$heightFactor = $srcH / $srcW;
}
else
{
$heightFactor = 1;
$widthFactor = $srcW / $srcH;
}
$width50 = 50 * $widthFactor;
$height50 = 50 * $heightFactor;
$width150 = 150 * $widthFactor;
$height150 = 150 * $heightFactor;
$thumb50 = imagecreatetruecolor(50, 50);
$thumb150 = imagecreatetruecolor(150, 150);
imagecopyresampled($thumb50, $srcImg, 0, 0, 0, 0, 50, 50, $srcW, $srcH); //the 0's can be changed to deal with centering
imagecopyresampled($thumb150, $srcImg, 0, 0, 0, 0, 50, 50, $srcW, $srcH); //the 0's can be changed to deal with centering
//save as png
imagepng($thumb50, "/tmp/somefinallocation50.png");
imagepng($thumb150, "/tmp/somefinallocation150.png");
Note: you'll have to add extra logic for centering and creating backround whitespace, if you want to deal with that stuff.
Acknowledgement: This example was taken from ActiveWAFL's DblEj\Multimedia\Image::ResampleAndSave()
method, with some code removed for ease of use.