代码之家  ›  专栏  ›  技术社区  ›  Anthony Kong

在imagemagick将肖像照片(JPG)转换为png文件后,将其转向侧面。如何阻止方向的改变?

  •  1
  • Anthony Kong  · 技术社区  · 6 年前

    原始照片如下所示:

    enter image description here

    我将it转换为 png 使用此命令:

    convert -strip -quiet -limit memory 2072580096 -quality 100 -alpha off -density 165% -scene 1 -colorspace sRGB tmpALcgg3.jpeg output.png
    

    转换后,会出现以下情况:

    enter image description here

    在Pixelmator中检查文件时,它显示为“1”

    enter image description here

    这对我来说并没有多大意义。

    然后我用 exiftool 从原始文件中提取以下信息

    ExifTool Version Number         : 10.80
    File Name                       : 5844997216141312-442620002-3d31fc32-9012-489e-88d2-177bf0bd679f (1).jpeg
    Directory                       : /Users/antkong/Downloads
    File Size                       : 3.2 MB
    File Modification Date/Time     : 2018:03:27 11:19:53+11:00
    File Access Date/Time           : 2018:03:27 11:52:56+11:00
    File Inode Change Date/Time     : 2018:03:27 11:20:00+11:00
    File Permissions                : rw-r--r--
    File Type                       : JPEG
    File Type Extension             : jpg
    MIME Type                       : image/jpeg
    Exif Byte Order                 : Big-endian (Motorola, MM)
    Make                            : NIKON CORPORATION
    Camera Model Name               : NIKON D90
    Orientation                     : Rotate 270 CW
    X Resolution                    : 300
    Y Resolution                    : 300
    Resolution Unit                 : inches
    Software                        : Ver.1.00
    Modify Date                     : 2018:03:12 22:23:48
    Y Cb Cr Positioning             : Co-sited
    Exposure Time                   : 1/30
    F Number                        : 4.5
    Exposure Program                : Not Defined
    ISO                             : 800
    Exif Version                    : 0221
    Date/Time Original              : 2018:03:12 22:23:48
    Create Date                     : 2018:03:12 22:23:48
    Components Configuration        : Y, Cb, Cr, -
    Compressed Bits Per Pixel       : 2
    Exposure Compensation           : 0
    Max Aperture Value              : 4.6
    Metering Mode                   : Multi-segment
    Light Source                    : Unknown
    Flash                           : Auto, Did not fire
    Focal Length                    : 40.0 mm
    Maker Note Version              : 2.10
    Quality                         : Normal
    White Balance                   : Auto
    Focus Mode                      : Manual
    Flash Setting                   : Normal
    Flash Type                      : 
    White Balance Fine Tune         : 0 0
    WB RB Levels                    : 1.26953125 1.9453125 1 1
    Program Shift                   : 0
    Exposure Difference             : 0
    Compression                     : JPEG (old-style)
    Preview Image Start             : 10204
    Preview Image Length            : 24280
    Flash Exposure Compensation     : 0
    ISO Setting                     : 800
    Image Boundary                  : 0 0 4288 2848
    External Flash Exposure Comp    : 0
    Flash Exposure Bracket Value    : 0.0
    Exposure Bracket Value          : 0
    Crop Hi Speed                   : Off (4352x2868 cropped to 4352x2868 at pixel 0,0)
    Exposure Tuning                 : 0
    Serial Number                   : 6726314
    VR Info Version                 : 0100
    Vibration Reduction             : On
    VR Mode                         : Normal
    Active D-Lighting               : Auto
    Picture Control Version         : 0100
    Picture Control Name            : Standard
    Picture Control Base            : Standard
    Picture Control Adjust          : Default Settings
    Picture Control Quick Adjust    : n/a
    Brightness                      : Normal
    Hue Adjustment                  : None
    Filter Effect                   : n/a
    Toning Effect                   : n/a
    Toning Saturation               : n/a
    Time Zone                       : +01:00
    Daylight Savings                : No
    Date Display Format             : D/M/Y
    ISO Expansion                   : Off
    ISO Expansion 2                 : Off
    Lens Type                       : G VR
    Lens                            : 18-105mm f/3.5-5.6
    Flash Mode                      : Did Not Fire
    Shooting Mode                   : Single-Frame, Auto ISO
    Shot Info Version               : 0213
    Firmware Version                : 1.00i
    ISO2                            : 800
    Light Switch                    : LCD Backlight
    AF Area Mode Setting            : Auto-area
    Center Focus Point              : Wide Zone
    AF Assist                       : On
    AF Point Illumination           : Auto
    Focus Point Wrap                : No Wrap
    AE Lock For MB-D80              : AE/AF Lock
    MB-D80 Battery Type             : LR6 (AA alkaline)
    Beep                            : On
    Grid Display                    : On
    ISO Display                     : Show ISO Sensitivity
    Viewfinder Warning              : On
    No Memory Card                  : Release Locked
    Screen Tips                     : On
    File Number Sequence            : Off
    Shooting Info Display           : Auto
    LCD Illumination                : Off
    Easy Exposure Comp              : Off
    Reverse Indicators              : + 0 -
    Exposure Control Step Size      : 1/3 EV
    Center Weighted Area Size       : 8 mm
    Fine Tune Opt Matrix Metering   : 0
    Fine Tune Opt Center Weighted   : 0
    Fine Tune Opt Spot Metering     : 0
    CL Mode Shooting Speed          : 3 fps
    Exposure Delay Mode             : Off
    Auto Bracket Set                : AE & Flash
    Auto Bracket Order              : 0,-,+
    Func Button                     : FV Lock
    OK Button                       : Select Center Focus Point
    AE Lock Button                  : AE/AF Lock
    Command Dials Reverse Rotation  : No
    Shutter Release Button AE-L     : Off
    Metering Time                   : 6 s
    Remote On Duration              : 1 min
    Self Timer Time                 : 10 s
    Self Timer Shot Count           : 1
    Playback Monitor Off Time       : 10 s
    Image Review Time               : 4 s
    Menu Monitor Off Time           : 20 s
    Shooting Info Monitor Off Time  : 10 s
    Flash Shutter Speed             : 1/60 s
    Internal Flash                  : TTL
    Manual Flash Output             : Full
    Repeating Flash Output          : 1/32
    Repeating Flash Count           : 10
    Repeating Flash Rate            : 10 Hz
    Flash Warning                   : On
    Commander Internal TTL Comp     : 0
    Modeling Flash                  : Off
    Auto FP                         : Off
    Commander Group A TTL Comp      : 0
    Commander Group B TTL Comp      : 0
    Live View AF                    : Wide Area
    Noise Reduction                 : Off
    WB GRBG Levels                  : 256 325 498 256
    Lens Data Version               : 0204
    Exit Pupil Position             : 102.4 mm
    AF Aperture                     : 4.6
    Focus Position                  : 0x32
    Focus Distance                  : 2.11 m
    Lens ID Number                  : 158
    Lens F Stops                    : 5.33
    Min Focal Length                : 18.3 mm
    Max Focal Length                : 106.8 mm
    Max Aperture At Min Focal       : 3.6
    Max Aperture At Max Focal       : 5.7
    MCU Version                     : 160
    Effective Max Aperture          : 4.6
    Retouch History                 : None
    Image Data Size                 : 3298230
    Shutter Count                   : 40069
    Flash Info Version              : 0103
    Flash Source                    : None
    External Flash Firmware         : n/a
    External Flash Flags            : (none)
    Flash Commander Mode            : Off
    Flash Control Mode              : Off
    Flash Compensation              : 0
    Flash GN Distance               : 0
    Flash Color Filter              : None
    Flash Group A Control Mode      : Off
    Flash Group B Control Mode      : Off
    Flash Group C Control Mode      : Off
    Flash Group A Compensation      : 0
    Flash Group B Compensation      : 0
    Flash Group C Compensation      : 0
    Vari Program                    : Auto
    Multi Exposure Version          : 0100
    Multi Exposure Mode             : Off
    Multi Exposure Shots            : 0
    Multi Exposure Auto Gain        : Off
    High ISO Noise Reduction        : Normal
    Power Up Time                   : 2018:03:12 22:05:11
    AF Info 2 Version               : 0100
    Contrast Detect AF              : Off
    AF Area Mode                    : Single Area
    Phase Detect AF                 : Off
    Primary AF Point                : (none)
    AF Points Used                  : (none)
    Contrast Detect AF In Focus     : No
    File Info Version               : 0100
    Memory Card Number              : 0
    Directory Number                : 100
    File Number                     : 0153
    Retouch Info Version            : 0100
    User Comment                    : 
    Sub Sec Time                    : 00
    Sub Sec Time Original           : 00
    Sub Sec Time Digitized          : 00
    Flashpix Version                : 0100
    Color Space                     : sRGB
    Exif Image Width                : 4288
    Exif Image Height               : 2848
    Interoperability Index          : R98 - DCF basic file (sRGB)
    Interoperability Version        : 0100
    Sensing Method                  : One-chip color area
    File Source                     : Digital Camera
    Scene Type                      : Directly photographed
    CFA Pattern                     : [Green,Blue][Red,Green]
    Custom Rendered                 : Normal
    Exposure Mode                   : Auto
    Digital Zoom Ratio              : 1
    Focal Length In 35mm Format     : 60 mm
    Scene Capture Type              : Standard
    Gain Control                    : Low gain up
    Contrast                        : Normal
    Saturation                      : Normal
    Sharpness                       : Normal
    Subject Distance Range          : Unknown
    GPS Version ID                  : 2.2.0.0
    Thumbnail Offset                : 34644
    Thumbnail Length                : 9197
    Image Width                     : 4288
    Image Height                    : 2848
    Encoding Process                : Baseline DCT, Huffman coding
    Bits Per Sample                 : 8
    Color Components                : 3
    Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
    Aperture                        : 4.5
    Auto Focus                      : Off
    Blue Balance                    : 1.945313
    Image Size                      : 4288x2848
    Lens ID                         : AF-S DX VR Zoom-Nikkor 18-105mm f/3.5-5.6G ED
    Lens Spec                       : 18-105mm f/3.5-5.6 G VR
    Megapixels                      : 12.2
    Preview Image                   : (Binary data 24280 bytes, use -b option to extract)
    Red Balance                     : 1.269531
    Scale Factor To 35 mm Equivalent: 1.5
    Shutter Speed                   : 1/30
    Create Date                     : 2018:03:12 22:23:48.00
    Date/Time Original              : 2018:03:12 22:23:48.00
    Modify Date                     : 2018:03:12 22:23:48.00
    Thumbnail Image                 : (Binary data 9197 bytes, use -b option to extract)
    Circle Of Confusion             : 0.020 mm
    Depth Of Field                  : 0.50 m (1.89 - 2.39 m)
    Field Of View                   : 32.8 deg (1.24 m)
    Focal Length                    : 40.0 mm (35 mm equivalent: 60.0 mm)
    Hyperfocal Distance             : 17.75 m
    Light Value                     : 6.2
    

    如上所示,方向设置为“旋转270 CW”,但它并不能真正解释结果。

    我想保持方向不变,因为当我在浏览器或应用程序(如pixelmator)中检查时,原始照片的方向是垂直的。

    我该怎么做?

    1 回复  |  直到 6 年前
        1
  •  3
  •   fmw42    6 年前

    您的EXIF数据显示:

    方向:顺时针旋转270

    因此,在命令行中添加-自动定向:

    convert -strip -quiet -limit memory 2072580096 -auto-orient tmpALcgg3.jpeg -quality 100 -alpha off -density 165% -scene 1 -colorspace sRGB  output.png