我的rails应用程序中有一个照片上传功能.该应用程序通过rmagick和雾直接通过carrierwave上传到s3.我遇到的问题是通过手机上的"拍照选项"上传照片时(注意这是iphone,但我相信Android有同样的问题).上传后,图像在手机上显示正常,但在桌面上查看时,图像会旋转90度.
通过我的研究,它看起来是exif的一个问题.此stackoverflow响应程序概述了2个可能的解决方案.这个要点也看起来也很有希望.
到目前为止,我发现了一些解决方案,但没有一个有效.理想情况下,我希望将照片作为肖像保存到s3,然后只按原样显示图像.
任何建议都很受欢迎.
以下是我的代码
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWaveDirect::Uploader
include CarrierWave::RMagick
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
include Sprockets::Helpers::RailsHelper
include Sprockets::Helpers::IsolatedHelper
include CarrierWave::MimeTypes
process :fix_exif_rotation
process :set_content_type
version :thumb do
process resize_to_fill: [200, 200]
end
def extension_white_list
%w(jpg jpeg png)
end
def fix_exif_rotation #this is my attempted solution
manipulate! do |img|
img = img.auto_orient!
end
end
end
Run Code Online (Sandbox Code Playgroud)
class S3Image < ActiveRecord::Base
attr_accessible :image, :name, :user_id …Run Code Online (Sandbox Code Playgroud) 此代码记录了foobar为零的记录
Model.where(user_id: 14, foobar: nil)
Run Code Online (Sandbox Code Playgroud)
我怎样才能使用相同的语法并获得NOT nil?
就像是:
Model.where(user_id: 14, foobar: !nil)
Run Code Online (Sandbox Code Playgroud) 这是 chromium-browser 的 CLI 命令
chromium-browser --kiosk --start-fullscreen /home/lando2319/WeatherWindow/home.html
这实际上可以很好地打开浏览器,但它给我留下了命令
[5488:5488:0520/174814.193710:ERROR:chrome_browser_cloud_management_controller.cc(162)] Cloud management controller initialization aborted as CBCM is not enabled.
Run Code Online (Sandbox Code Playgroud)
不幸的是,这只是挂起,最终当我按下 control c 时,它会退出窗口。
你知道我怎样才能打开这个窗口而不被这条消息劫持吗?
Stackoverflow 上有几十个关于 Swift 5 中 mailto 链接的答案。
共识看起来像这样
let url = NSURL(string: "mailto:jon.doe@mail.com")
UIApplication.sharedApplication().openURL(url)
Run Code Online (Sandbox Code Playgroud)
但我该如何实际使用这段代码呢?最好是在警报中,但至少是一般的文本元素
import SwiftUI
struct MainMenu: View {
@State private var showAlert = false
// What do I put here
var emailLink:UIApplication {
let url = URL(string: "mailto:jon.doe@mail.com")!
return UIApplication.shared.openURL(url)
}
// To make it work in here
var body: some View {
HStack(alignment: .center, spacing: .zero, content: {
Text(
"Here is an email link \(emailLink)"
)
Button(action: {
showAlert = true
}) {
Text("MENU")
}
.alert(isPresented: …Run Code Online (Sandbox Code Playgroud) activerecord ×1
amazon-s3 ×1
carrierwave ×1
chromium ×1
exif ×1
mailto ×1
raspberry-pi ×1
rmagick ×1
shell ×1
swift ×1
swift5 ×1
swiftui ×1