84899

How to detect if video is Landscape/portrait when fetched from PHAsset?

I am fetching videos from PHAsset so user can choose the video and import to perform edit. But user should be only able to select video with Landscape orientation, if user select portrait video, she/he would get alert message saying that its portrait video and hence can not import to edit.

One way to do this is creating AVAsset from URL of PHFetchResults, and then checking a preferedTransform, but that would be very costly operation to do right?

Is there a way to do this without creating AVasset?

Answer1:

https://developer.apple.com/library/ios/documentation/Photos/Reference/PHAsset_Class/

<strong>var pixelWidth: Int { get }</strong>

<strong>var pixelHeight: Int { get }</strong>

The width and height, in pixels, of the asset’s image or video data. (read-only)

If the asset’s content has been edited, this property describes the size of the current version of the asset. Availability iOS (8.0 and later)

if asset!.pixelHeight > asset!.pixelWidth { // will be portrait video or Image }

<strong>Available in iOS 8.0 and later.</strong>

Recommend

  • Adding metadata to AAC M4A via AVAssetExportSession
  • Duet - Merge 2 Videos Side by Side
  • How to get to older Xcode beta version?
  • Peer to peer/adaptive payments with paypal [closed]
  • why fullscreen functionality is not working in chrome?
  • Rails 3.2 from SQLite locally to Postgres on Heroku
  • Javascript unload page condition
  • How to resolve dependencies from one gradle project to another gradle project in my Eclipse workspac
  • Basic defensive programming [duplicate]
  • FTS3 searches in ORMLite?
  • Distributed JMS based logging .. falling flat?
  • Specifying virtual keyboard type for EditText in XML
  • Tools for understanding HTML layout
  • What is the difference between a “service account” and an “installed application”?
  • Where can I find tomesh.c?
  • Can I use AllJoyn Framework for Wifi Direct in iOS?
  • How to set elevation color?
  • Who propagate bugfixes across branches (corporate development)?
  • Moving Android View and preventing onDraw to be called over and over again
  • Retrieve list of sent friend requests from friend_request FQL table
  • Installing iPhone App to iPhone
  • Xcode 4 NSLog Macro link in Xcode 3
  • NHibernate Validation Localization with S#arp Architecture
  • Asynchronous UI Testing in Xcode With Swift
  • Initializer list vs. initialization method
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • Control modification in presentation layer
  • Why is an OPTIONS request sent to the server?
  • Exchange data b/w iOS devices using Bluetooth 4.0
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Fetching methods from BroadcastReceiver to update UI
  • Accessing IRQ description array within a module and displaying action names
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Circular dependency while pushing http interceptor
  • AngularJs get employee from factory
  • How to set the response of a form post action to a iframe source?
  • Getting Messege Twice Using IMvxMessenger
  • Change div Background jquery
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass