Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function for media orientation check #23

Open
zhm opened this issue Sep 21, 2016 · 0 comments
Open

Add function for media orientation check #23

zhm opened this issue Sep 21, 2016 · 0 comments

Comments

@zhm
Copy link
Member

zhm commented Sep 21, 2016

We should add a helper to check the orientation of media. A helper is needed to account for the non-intuitive (but correct) EXIF orientation values.

Here is a proposed implementation:

function ISPORTRAIT(value) {
  var width = value.width;
  var height = value.height;

  // photos
  if (value.orientation === 6 || value.orientation === 8) {
    width = value.height;
    height = value.width;
  }

  // videos
  if (value.orientation === 90 || value.orientation === 270) {
    width = value.height;
    height = value.width;
  }

  return width < height;
}

Usage:

ON('add-photo', 'photos', function(event) {
  if (ISMOBILE() && ISPORTRAIT(event.value)) {
    INVALID('Please retake the photo in landscape orientation.');
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant