javascript - 为什么图像文件输入会横向显示(翻转)?
问题描述
所以我目前在 Vuejs 中有一个组件,用户可以从他们的本地文件系统中选择一个文件。用户选择图像后,图像会在div
代码框中预览。出于某种原因,一些图像会自动“翻转”到一边。主要是来自手机的图像,高度远大于宽度。
<div
id="capture"
class="image-input"
:style="{ 'background-image': `url(${img})` } "
@click="chooseImage"
>
<span v-if="!img" class="placeholder">
<i class="el-icon-plus avatar-uploader-icon"></i>
</span>
<input type="file" ref="fileInput" @change="previewImage">
</div>
.image-input {
display: block;
width: 150px;
height: 150px;
cursor: pointer;
background-size: cover;
background-position: center center;
margin-bottom: 20px;
}
在代码框中,您可以上传图像并显示预览。我也包含img2
在数据属性中。如果你设置:style="{ 'background-image': `url(${img})` } "
你img2
可以明白我的意思。基本上:gyazo
如何正确显示图像?没有翻转。
解决方案
The image is actually rotated and your software is rotating it back using metadata hints.
You should either physically rotate the image, or use a css transform.
推荐阅读
- reactjs - 成功操作完成后更新一些组件
- sql - 如何在 DB2 LUW 的存储过程中使用 COMMIT
- angular - Angular Firebase auth,如何检查用户是否登录以隐藏登录链接?
- c# - 使用 Html.BeginForm() 搜索两个参数
- java - 如何定义对未知模块的合格导出?
- php - 如何从分号分隔的字符串中获取值
- excel - 移动带有插入行的形状,其中 Application.ScreenUpdating = False
- python - gpxpy:从 gpx 文件中获取扩展值
- r - RStudio tfestimator 不适用于 tensorflow 的分发策略
- javascript - 如何保存显示用 javascript 编写的测试结果的动态 html 页面