旋转的图片

旋转的图片

我是视频编码的新手。我的问题是:我有一组照片,其中一些是用我的相机旋转 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

相关内容