旋轉圖片

旋轉圖片

我是影片編碼的新手。我的問題是:我有一組照片,其中一些是用我的相機旋轉 90 度拍攝的。我嘗試使用 mencoder 與它們一起製作電影,但結果顯示旋轉相機製作的照片看起來不會旋轉。如何製作一部尊重原始圖片方向的電影?我混合了旋轉的圖片和未旋轉的圖片。誰能幫我?

答案1

幾年前我為此目的編寫了一個腳本。我稱之為自腐,但您可以使用任何名稱。你應該修改變數

dimkonica=2112x2816
dimcanon=3264x2448

與您的圖片尺寸相符的值。這是腳本:

#!/bin/bash

if [ "$1" == "" ]
then
 echo "Usage: $0 <jpeg-file> [lossy]"
 echo "Auto-rotate *lossless* with jhead,"
 echo "or optionally, if bad image dimensions,"
 echo "auto-orient *lossy* with convert"
 exit
fi
name="$1"
name=${name%.*}
#echo $1
#echo $name
if [ "$1" == "$name".jpg ] || [ "$1" == "$name".JPG ] || [ "$1" == "$name".jpeg ] || [ "$1" == "$name".JPEG ]
then
 echo hej>/dev/null
else
 echo "Bad! $1 not a jpeg-file"
 exit
fi

dimkonica=2112x2816
dimcanon=3264x2448

dim=$(identify -ping "$1"|sed -e s/.*JPEG\ // -e s/\ .*//)
gw0=$(echo "$dim"|sed s/x.*//)
gw1=$((gw0/16*16))
gh0=$(echo "$dim"|sed s/.*x//)
gh1=$((gh0/16*16))

if [ "$dim" == "$dimkonica" ] || [ "$dim" == "$dimcanon" ]
then
  echo "jhead: Original dimension for jhead: $1: $dim"
  jhead -autorot "$1"
else
 if [ "$gw0" == "$gw1" ] && [ "$gh0" == "$gh1" ]
 then
  echo "jhead: Good dimension for jhead: $1: $gw0"x"$gh0"
  jhead -autorot "$1"
 else
  if [ "$2" == "lossy" ]
  then
   echo "convert: Bad dimension for jhead: $1: $dim"
   while [ "$ans" != "yes" ] && [ "$ans" != "n" ] && [ "$ans" != "no" ]
   do
    echo -n "make a lossy rotation the image? (yes/no) "
    read ans
    if [ "$ans" == "yes" ]
    then
     echo Converted: original saved, rotated copy named "$name"_r.jpg
     convert -auto-orient "$1" "$name"_r.jpg
    fi
   done
  else
   echo "Bad dimension for jhead: $1: $dim"
  fi
 fi
fi

相關內容