10 examples of 'react native image resizemode' in JavaScript

Every line of 'react native image resizemode' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
595resize(width: number, height: number) {
596 this._eventLayer.style.width = `${width}px`;
597 this._eventLayer.style.height = `${height}px`;
598 this.compositor.resizeCanvas(width, height);
599}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

121set resizeMode(value: number) {
122 switch (value) {
123 case resizeModes.ScaleNone: {
124 this.videoElement.style.objectFit = "none";
125 break;
126 }
127 case resizeModes.ScaleToFill: {
128 this.videoElement.style.objectFit = "fill";
129 break;
130 }
131 case resizeModes.ScaleAspectFit: {
132 this.videoElement.style.objectFit = "contain";
133 break;
134 }
135 case resizeModes.ScaleAspectFill: {
136 this.videoElement.style.objectFit = "cover";
137 break;
138 }
139 }
140}
4export default async function resizeImage(src, el, targetDimensions) {
5 const pica = Pica();
6 const from = document.createElement('canvas');
7 const fromContext = from.getContext('2d');
8 const to = document.createElement('canvas');
9
10 const fromImage = new Image();
11 fromImage.src = src;
12
13 const stats = await getImageStats(fromImage);
14 const newDimensions = getNewDimensions(stats, targetDimensions);
15
16 from.width = stats.width;
17 from.height = stats.height;
18 to.height = newDimensions.height;
19 to.width = newDimensions.width;
20
21 fromContext.drawImage(fromImage, 0, 0);
22
23 const result = await pica.resize(from, to);
24 const blob = await pica.toBlob(result, stats.mimeType);
25 const dataUrl = await blobToDataURL(blob);
26
27 return { blob, dimensions: newDimensions, src: dataUrl };
28}
22var withResizeDetector = function withResizeDetector(WrappedComponent) {
23 var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
24 handleWidth: true,
25 handleHeight: true
26 };
27 return (
28 /*#__PURE__*/
29 // eslint-disable-next-line
30 function (_Component) {
31 _inherits(ResizeDetectorHOC, _Component);
32
33 function ResizeDetectorHOC() {
34 _classCallCheck(this, ResizeDetectorHOC);
35
36 return _possibleConstructorReturn(this, _getPrototypeOf(ResizeDetectorHOC).apply(this, arguments));
37 }
38
39 _createClass(ResizeDetectorHOC, [{
40 key: "render",
41 value: function render() {
42 return React.createElement(ResizeDetector, props, React.createElement(WrappedComponent, this.props));
43 }
44 }]);
45
46 return ResizeDetectorHOC;
47 }(Component)
48 );
49};
111reSize(image, params) {
112 // 原始图片宽高
113 const width = this.pixelWidth;
114 const height = this.pixelHeight;
115 // 缩放后的宽高
116 let sw = width;
117 let sh = height;
118 // 最小边缩放到scale
119 if (width < height) {
120 sw = params.scale;
121 sh = Math.round(sw * height / width);
122 } else {
123 sh = params.scale;
124 sw = Math.round(sh * width / height);
125 }
126 this.fromPixels2DContext.canvas.width = sw;
127 this.fromPixels2DContext.canvas.height = sh;
128 this.fromPixels2DContext.drawImage(
129 image, 0, 0, sw, sh);
130 return {sw, sh};
131};
26componentDidMount() {
27 Image.getSize(this.props.uri, (width, height) => {
28 this.setState({
29 imgHeight: (maxWidth / width) * height,
30 });
31 });
32}
75resize() {
76 CompressImage.createCompressedImage(this.state.image.uri, 'Compress/Images')
77 .then(({uri}) => {
78 console.log(uri);
79 this.setState({
80 compressedImageUri: uri,
81 });
82 }).catch((err) => {
83 console.log(err);
84 return Alert.alert('Unable to compress photo, Check the console for full the error message');
85 });
86}
30resizeByHeight (height) {
31 this.image.resize(null, height)
32}
50handleLoad() {
51 this.domElement.contentDocument.defaultView.addEventListener(
52 'resize',
53 this.props.onResize
54 );
55}
92createEl() {
93 return super.createEl('iframe', {
94 className: 'vjs-resize-manager',
95 tabIndex: -1
96 }, {
97 'aria-hidden': 'true'
98 });
99}

Related snippets