I create a thumbnail of an image create by user's phone with php on sql server, but the thumb result rotate by 90°.
this is the code:
function generateThumbnail($imgk, $width, $height, $quality)
{
if (is_file($imgk)) {
$imagick = new Imagick(realpath($imgk));
$imagick->setImageFormat('jpeg');
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
$imagick->setImageCompressionQuality($quality);
$imagick->thumbnailImage($width, $height, false, false);
$filename_no_ext = reset(explode('.', $imgk));
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
throw new Exception("Could not put contents.");
}
return true;
}
else {
throw new Exception("No valid image provided with {$imgk}.");
}
}
the result are like this (in most of image):
Maybe the exif data is the problem but I don't have idea for solution.