I have a PHP script which runs perfectly in our current VPS. But it is giving Internal server error when I run the same script in our new VPS (Amazon).
This script's job is to rotate an image horizontally. But not sure why its giving internal server error. Also, its not logging anything in apache error log. Logging is on in Apache. So, I am clueless what might causing it.
Below is the script and its failing at line "$rotated = @imagerotate($dst_img, $angle, 0);"
<?php
function RotateJpg($filename = '',$angle = 0,$savename = false){
header('Content-type: image/png');
$original = @imagecreatefrompng($filename);
$srcsize = @getimagesize($filename);
$dest_x = 2000;
$dest_y = (2000 / $srcsize[0]) * $srcsize[1];
$dst_img = @imagecreatetruecolor($dest_x, $dest_y);
@imagecopyresampled($dst_img, $original, 0, 0, 0, 0,$dest_x, $dest_y, $srcsize[0], $srcsize[1]);
@imagedestroy($original);
$rotated = @imagerotate($dst_img, $angle, 0);
@imagedestroy($dst_img);
if($savename == false) {
header('Content-Type: image/png');
@imagepng($rotated);
}
else{
@imagepng($rotated,$savename);
}
imagedestroy($rotated);
}
RotateJpg('source_file',90,'destination_file');
?>
I will really appreciate your help.
Regards,
EDITED
When I am adding below code, its not giving me 500 internal server error but giving 200 success. However it just show me blank page without image rotation.
error_reporting(E_ALL);
ini_set('display_errors', 1);
I have verified GD is enabled on the server.
You should definitely remove all the
@
from your code (it disables errors and warnings).My guess would be that GD is not active on the server. You should try to add GD to your php.