Search code examples
javascriptphpimagetransloadit

Transloadit - Image auto-rotation not working


In my project I implemented image upload using Transloadit API, all the properties are working properly except rotation. When I hardcoded the rotation value then it is working proper and the uploaded image is rotated correctly. But when I try auto-rotation of an image by setting its rotation : true it's not working. I tried it with too many images but it looks as there was a problem in my code. Here is my code file "Index.html":

<html>
<head><title>Title</title></head>
<body>
<form action="/image/upload.php" enctype="multipart/form-data" method="POST">
  <input type="file" name="my_file" multiple="multiple" />
</form>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="https://assets.transloadit.com/js/jquery.transloadit2-v2-latest.js"></script>
<script type="text/javascript">
$(function() 
{
    $('form').transloadit(
    {
        wait: true,
        triggerUploadOnFileSelection: true,
        params: 
        {
            auth: 
            { 
                key: "MY_API_KEY" 
            }, 
            steps: 
            {
                thumb: 
                {
                    use: ":original",
                    robot: "/image/resize",
                    result: true,
                    rotation: true
                }
            }
        }
    });
});
</script>
</body>
</html>

My PHP code

<?php
$result = $_POST['transloadit'];
if (ini_get('magic_quotes_gpc') === '1') 
{
    $result = stripslashes($result);
}
$result = json_decode($result, true);
echo "<pre>";
print_r($result);
?>

Solution

  • I asked the same question with the support team of Transloadit and finally got this answer from the support team

    It looks like the image contains the meta rotation data in a format, that imagemagick does not understand (yet). We'll soon have a new version of ImageMagick behind the scenes, which might fix this. But I cannot give you an exact date yet of when this will be live. However, our auto-rotation should work in 99.9% of the use cases.