Command line 使用imagemagick设置图像方向exif数据

Command line 使用imagemagick设置图像方向exif数据,command-line,imagemagick,mogrify,Command Line,Imagemagick,Mogrify,我有一组带有损坏的exif方向数据的图像。我想使用imagemagick更改这些图像的方向。我发现了下面的命令mogrify-set“%[EXIF:Orientation]”右下角的image.jpg,但当我使用identifite-verbose image检查图像时,它似乎不起作用。jpg方向数据未定义。不确定是否/如何使用ImageMagick,但您可能希望按如下方式使用exiftool: # Set orientation with exiftool exiftool -Orientat

我有一组带有损坏的exif方向数据的图像。我想使用imagemagick更改这些图像的方向。我发现了下面的命令
mogrify-set“%[EXIF:Orientation]”右下角的image.jpg
,但当我使用
identifite-verbose image检查图像时,它似乎不起作用。jpg
方向数据未定义。

不确定是否/如何使用ImageMagick,但您可能希望按如下方式使用exiftool:

# Set orientation with exiftool
exiftool -Orientation=3 -n input.jpg
1 image files updated

# Check with **ImageMagick** 
identify -verbose input.jpg | grep rient
Orientation: BottomRight
exif:Orientation: 3
下面是一个测试所有8个值的小循环:

for x in {1..8}; do 
   exiftool -Orientation=$x -n input.jpg > /dev/null
   identify -verbose input.jpg | grep Orientation
done

  Orientation: TopLeft
    exif:Orientation: 1
  Orientation: TopRight
    exif:Orientation: 2
  Orientation: BottomRight
    exif:Orientation: 3
  Orientation: BottomLeft
    exif:Orientation: 4
  Orientation: LeftTop
    exif:Orientation: 5
  Orientation: RightTop
    exif:Orientation: 6
  Orientation: RightBottom
    exif:Orientation: 7
  Orientation: LeftBottom
    exif:Orientation: 8

使用ImageMagick,您可以通过以下方式进行操作:

mogrify-orient*.jpg

有效的方向是

bottom-left    
right-top
bottom-right   
top-left
left-bottom    
top-right
left-top       
undefined
right-bottom 
更多信息

您可以使用identify验证更改:

identify-verbose input.jpg | grep-Orientation