GithubHelp home page GithubHelp logo

Customizable size about ngx-webcam HOT 11 CLOSED

basst314 avatar basst314 commented on August 31, 2024 4
Customizable size

from ngx-webcam.

Comments (11)

sam-lex avatar sam-lex commented on August 31, 2024 11

If you want to make it "responsive full screen", then this will work for you.

Not sure about custom responsive solutions, you could tweak it by doing the calculations yourself if it's not too complicated.

export class TakePictureComponent implements OnInit {
  private width: number;
  private height: number;

  @HostListener('window:resize', ['$event'])
  onResize(event?: Event) {
    const win = !!event ? (event.target as Window) : window;
    this.width = win.innerWidth;
    this.height = win.innerHeight;
  }

  constructor() {
    this.onResize();
  }
  // ...
}
<div class="wrapper" (window:resize)="onResize($event)">
  <!-- Webcam -->
  <webcam [trigger]="triggerObservable"
      [width]="width"
      [height]="height"
      (imageCapture)="onImageCapture($event)">
  </webcam>

  <!-- Controls -->
</div>
.wrapper {
  display: flex;
  background: #383838;
  height: 100vh;
  align-items: center;
  justify-content: center;
  // inexplicable/unknown extra space is rendered, causing scrollbars to show up 
  overflow: hidden;
}

from ngx-webcam.

basst314 avatar basst314 commented on August 31, 2024 5

Hi @sam-lex,

Thanks for sharing your solution. I will try to enhance the library by providing better resizeability out-of-the-box soon.
I will leave this issue open to keep you posted!

Cheers!

from ngx-webcam.

ILDEMONICO avatar ILDEMONICO commented on August 31, 2024 1

Is this workaround still valid? i'm trying to change component size according to an user event (i need to change from 16:9 aspect ratio to 1:1) but everytime i try to change the size, the video tag always set itself to maximum visible space with the aspect ratio setted in first instance reagrdless of any value i try to set

from ngx-webcam.

basst314 avatar basst314 commented on August 31, 2024

Do you mean by putting the webcam component in a container with predefined size, or do you mean the user should be able to resize the webcam component at runtime?

from ngx-webcam.

lexcaraig avatar lexcaraig commented on August 31, 2024

Well, i think the width and height should be responsive so anyone can just resize the container at runtime or not. :) Bec, I did some hook just to make it responsive.

Setting a fix size would be also nice.

from ngx-webcam.

rickdroio avatar rickdroio commented on August 31, 2024

it is possible to set width and height like this:

<webcam [width]="320" [height]="240"></webcam>

from ngx-webcam.

brayanmcz avatar brayanmcz commented on August 31, 2024

@rickdroio We're you able to get your camera to resize using the code you used above?
I tried it and it did not work for me.

from ngx-webcam.

basst314 avatar basst314 commented on August 31, 2024

Closing this issue, current resizing capabilities should be sufficient for now

from ngx-webcam.

vamsikrishna18 avatar vamsikrishna18 commented on August 31, 2024

how can we set the width for maximum screen

from ngx-webcam.

Nitin1121 avatar Nitin1121 commented on August 31, 2024

We cant get the camera width & height to entire screen size by using the above mentioned code...We cant able to modify its dimension by using css it doesnt get applied ...can someone suggest any ways to get it fullscreen

from ngx-webcam.

sayedgt avatar sayedgt commented on August 31, 2024

How to set focus distance? Any sample code will be appreciated.

from ngx-webcam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.