我如何避免Github在readme.md中旋转我的jpg?

ste*_*hin 11 markdown jpeg github orientation github-flavored-markdown

readme.md在github上添加了一个图像引用.图片是纵向格式照片,但是当我在github页面上查看时,图片会旋转.

我已经尝试将回购克隆到一个新的位置,以确认图片确实仍然像回购中预期的那样.

readme.md的图像部分:

Here is a picture of the hardware setup. ![picture of the hardware setup](HelloButtonModule.jpg)
Run Code Online (Sandbox Code Playgroud)

这是受影响的github回购

更新

现在我感到困惑,我试图在一个新的回购中简化问题,但图片显示未旋转为(最初)预期.

更新

我创建了一个带有图片精确副本的仓库.然后旋转图片.

小智 15

您可以尝试简单地打开文件然后重新保存它.在保存之前,您可能需要旋转360度,但这应该有效.


tex*_*ood 5

如果您使用的是基于Debian的发行版,则可以使用exiftran

sudo apt-get install exiftran
exiftran -ai *.jpg
Run Code Online (Sandbox Code Playgroud)

这将根据它们的exif数据自动旋转所有.jpg文件。

我跑了

git clone https://github.com/steenhulthin/HelloButtonModule/
cd HelloButtonModule/
exif HelloButtonModule.jpg
Run Code Online (Sandbox Code Playgroud)

这产生了:

EXIF tags in 'HelloButtonModule.jpg' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag                 |Value
--------------------+----------------------------------------------------------
Image Width         |4128
Image Length        |2322
Manufacturer        |SAMSUNG
Model               |GT-I9505
Orientation         |Top-left
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Software            |I9505XXUDMH8
Date and Time       |2013:10:16 23:22:57
YCbCr Positioning   |Centred
Image Width         |512
Image Length        |288
Compression         |JPEG compression
Orientation         |Right-top
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Exposure Time       |1/33 sec.
F-Number            |f/2.2
Exposure Program    |Normal programme
ISO Speed Ratings   |100
Exif Version        |Exif Version 2.2
Date and Time (Origi|2013:10:16 23:22:57
Date and Time (Digit|2013:10:16 23:22:57
Components Configura|Y Cb Cr -
Shutter Speed       |5.06 EV (1/33 sec.)
Aperture            |2.28 EV (f/2.2)
Brightness          |2.44 EV (18.56 cd/m^2)
Exposure Bias       |0.00 EV
Maximum Aperture Val|2.28 EV (f/2.2)
Metering Mode       |Centre-weighted average
Light Source        |Unknown
Flash               |Flash did not fire
Focal Length        |4.2 mm
Maker Note          |98 bytes undefined data
User Comment        |METADATA-START
FlashPixVersion     |FlashPix Version 1.0
Colour Space        |sRGB
Pixel X Dimension   |4128
Pixel Y Dimension   |2322
Sensing Method      |One-chip colour area sensor
Run Code Online (Sandbox Code Playgroud)

如您所见,“方向”标签显示在左上方。这意味着EXIF数据不会改变旋转,即图像在计算机和Github上将显示相同。

然后我跑了

git clone https://github.com/steenhulthin/githubreadmeimagerotation2
cd githubreadmeimagerotation2/
exif HelloButtonModule.jpg
Run Code Online (Sandbox Code Playgroud)

我得到:

EXIF tags in 'HelloButtonModule.jpg' ('Intel' byte order):
--------------------+----------------------------------------------------------
Tag                 |Value
--------------------+----------------------------------------------------------
Image Width         |4128
Image Length        |2322
Manufacturer        |SAMSUNG
Model               |GT-I9505
Orientation         |Right-top
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Software            |I9505XXUDMH8
Date and Time       |2013:10:16 23:22:57
YCbCr Positioning   |Centred
Image Width         |512
Image Length        |288
Compression         |JPEG compression
Orientation         |Right-top
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Exposure Time       |1/33 sec.
F-Number            |f/2.2
Exposure Program    |Normal programme
ISO Speed Ratings   |100
Exif Version        |Exif Version 2.2
Date and Time (Origi|2013:10:16 23:22:57
Date and Time (Digit|2013:10:16 23:22:57
Components Configura|Y Cb Cr -
Shutter Speed       |5.06 EV (1/33 sec.)
Aperture            |2.28 EV (f/2.2)
Brightness          |2.44 EV (18.56 cd/m^2)
Exposure Bias       |0.00 EV
Maximum Aperture Val|2.28 EV (f/2.2)
Metering Mode       |Centre-weighted average
Light Source        |Unknown
Flash               |Flash did not fire
Focal Length        |4.2 mm
Maker Note          |98 bytes undefined data
User Comment        |METADATA-START
FlashPixVersion     |FlashPix Version 1.0
Colour Space        |sRGB
Pixel X Dimension   |4128
Pixel Y Dimension   |2322
Sensing Method      |One-chip colour area sensor
Run Code Online (Sandbox Code Playgroud)

这里的方向说明Right-top这意味着图像的右上角当前位于左上角。Github不接受此信息,因此您的图像显示不正确。

然后我跑了exiftran -ai HelloButtonModule.jpg,这解决了问题。https://github.com/texasflood/githubreadmeimagerotation2这里有一个叉子,它显示了图像的正确旋转。

如果您使用的是Windows,则可以通过以下问题使用IrfanView:https : //superuser.com/questions/36645/how-to-rotate-images-automatically-based-on-exif-data


A. *_*nda 4

我认为这是由于 github 缺少对 EXIF“Orientation”标签的支持造成的。

Github 显示 JPEG 文件中包含的图像数据,这是相机光电传感器捕获图像的方向。另外,JPEG文件包括包含值“右、上”的EXIF标签“方向”,其指示图像数据不按原样解释,而是右侧实际上应该朝上。显然,github 不尊重这个标签。

第二个存储库中的图像与第一个存储库中的图像不同,但似乎已被编辑以添加红色箭头和文本。我的猜测是,编辑器在加载过程中解释了“方向”标签,然后以旋转形式保存图像数据,并将“方向”标签值设置为“上,左”。

有关详细信息,请参阅JPEG 旋转和 EXIF 方向等