Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Fixing orientation when sending images & videos from Iphone.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 272
    Comment on it

    Hi all, for fixing the rotation problem when image/video is taken from Iphone, we can have following cases:

    1. When creating a thumbnail from an image and then getting its orientation correct, we can use shell command like this:
      shell_exec("convert $uploadfile  -auto-orient -resize 195x260  $thumbpath");
      
    2. When creating a thumbnail from a video, first we have to check orientation of that video. For checking the orientation we need to install mediainfo package on our server. After installing mediainfo package we can check the orientation using this command:
      $check_orientation = shell_exec("mediainfo $uploadfile | grep Rotation");
      // In $uploadfile pass the location of video with video name.
      print_r($check_orientation);
      
      If $check_orientation is not null it will give following value depending on video's orientation:
      • Rotation : 90
      • Rotation : 180
      • Rotation : 270
        If $check_orientation is null then orientation of video is correct. Depending on the rotation we can rotate our thumbnail which we will create from video using this command:
        shell_exec("ffmpeg -i ".$uploadfile."  -ss 00:00:1.999 -s 260x195 -f image2 -vframes 1 ".$dirPath_videoThumb.$only_name.".png &"); // Command for creating the thumbnail from video
        shell_exec("mogrify -rotate 90 $videoThumbname"); //command for rotating the thumbnail without creating the copy.
        shell_exec("mogrify -rotate 180 $videoThumbname");
        shell_exec("mogrify -rotate 270 $videoThumbname");
        
        Use these command depending on the output of $check_orientation. We can make cases using switch case for checking and then rotating the image accordingly.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: