Passed
Push — master ( 340603...3658d8 )
by Roeland
14:34 queued 11s
created
lib/private/Preview/WebP.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,6 @@
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	public function isAvailable(FileInfo $file): bool {
40
-		return (bool)(imagetypes() && IMG_WEBP);
40
+		return (bool) (imagetypes() && IMG_WEBP);
41 41
 	}
42 42
 }
Please login to merge, or discard this patch.
lib/private/legacy/OC_Image.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function widthTopLeft() {
145 145
 		$o = $this->getOrientation();
146
-		$this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, ['app' => 'core']);
146
+		$this->logger->debug('OC_Image->widthTopLeft() Orientation: '.$o, ['app' => 'core']);
147 147
 		switch ($o) {
148 148
 			case -1:
149 149
 			case 1:
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function heightTopLeft() {
169 169
 		$o = $this->getOrientation();
170
-		$this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, ['app' => 'core']);
170
+		$this->logger->debug('OC_Image->heightTopLeft() Orientation: '.$o, ['app' => 'core']);
171 171
 		switch ($o) {
172 172
 			case -1:
173 173
 			case 1:
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		if ($mimeType === null) {
195 195
 			$mimeType = $this->mimeType();
196 196
 		}
197
-		header('Content-Type: ' . $mimeType);
197
+		header('Content-Type: '.$mimeType);
198 198
 		return $this->_output(null, $mimeType);
199 199
 	}
200 200
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		}
213 213
 		if ($filePath === null) {
214 214
 			if ($this->filePath === null) {
215
-				$this->logger->error(__METHOD__ . '(): called with no path.', ['app' => 'core']);
215
+				$this->logger->error(__METHOD__.'(): called with no path.', ['app' => 'core']);
216 216
 				return false;
217 217
 			} else {
218 218
 				$filePath = $this->filePath;
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 			}
237 237
 			$isWritable = is_writable(dirname($filePath));
238 238
 			if (!$isWritable) {
239
-				$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', ['app' => 'core']);
239
+				$this->logger->error(__METHOD__.'(): Directory \''.dirname($filePath).'\' is not writable.', ['app' => 'core']);
240 240
 				return false;
241 241
 			} elseif ($isWritable && file_exists($filePath) && !is_writable($filePath)) {
242
-				$this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', ['app' => 'core']);
242
+				$this->logger->error(__METHOD__.'(): File \''.$filePath.'\' is not writable.', ['app' => 'core']);
243 243
 				return false;
244 244
 			}
245 245
 		}
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 					$imageType = IMAGETYPE_BMP;
268 268
 					break;
269 269
 				default:
270
-					throw new Exception('\OC_Image::_output(): "' . $mimeType . '" is not supported when forcing a specific output format');
270
+					throw new Exception('\OC_Image::_output(): "'.$mimeType.'" is not supported when forcing a specific output format');
271 271
 			}
272 272
 		}
273 273
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 			return;
453 453
 		}
454 454
 
455
-		$exif = @exif_read_data('data://image/jpeg;base64,' . base64_encode($data));
455
+		$exif = @exif_read_data('data://image/jpeg;base64,'.base64_encode($data));
456 456
 		if (!$exif) {
457 457
 			return;
458 458
 		}
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	 */
471 471
 	public function fixOrientation() {
472 472
 		$o = $this->getOrientation();
473
-		$this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, ['app' => 'core']);
473
+		$this->logger->debug('OC_Image->fixOrientation() Orientation: '.$o, ['app' => 'core']);
474 474
 		$rotate = 0;
475 475
 		$flip = false;
476 476
 		switch ($o) {
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 					imagealphablending($this->resource, true);
568 568
 					imagesavealpha($this->resource, true);
569 569
 				} else {
570
-					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, ['app' => 'core']);
570
+					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: '.$imagePath, ['app' => 'core']);
571 571
 				}
572 572
 				break;
573 573
 			case IMAGETYPE_JPEG:
@@ -575,10 +575,10 @@  discard block
 block discarded – undo
575 575
 					if (getimagesize($imagePath) !== false) {
576 576
 						$this->resource = @imagecreatefromjpeg($imagePath);
577 577
 					} else {
578
-						$this->logger->debug('OC_Image->loadFromFile, JPG image not valid: ' . $imagePath, ['app' => 'core']);
578
+						$this->logger->debug('OC_Image->loadFromFile, JPG image not valid: '.$imagePath, ['app' => 'core']);
579 579
 					}
580 580
 				} else {
581
-					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, ['app' => 'core']);
581
+					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: '.$imagePath, ['app' => 'core']);
582 582
 				}
583 583
 				break;
584 584
 			case IMAGETYPE_PNG:
@@ -588,21 +588,21 @@  discard block
 block discarded – undo
588 588
 					imagealphablending($this->resource, true);
589 589
 					imagesavealpha($this->resource, true);
590 590
 				} else {
591
-					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, ['app' => 'core']);
591
+					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: '.$imagePath, ['app' => 'core']);
592 592
 				}
593 593
 				break;
594 594
 			case IMAGETYPE_XBM:
595 595
 				if (imagetypes() & IMG_XPM) {
596 596
 					$this->resource = @imagecreatefromxbm($imagePath);
597 597
 				} else {
598
-					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, ['app' => 'core']);
598
+					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagePath, ['app' => 'core']);
599 599
 				}
600 600
 				break;
601 601
 			case IMAGETYPE_WBMP:
602 602
 				if (imagetypes() & IMG_WBMP) {
603 603
 					$this->resource = @imagecreatefromwbmp($imagePath);
604 604
 				} else {
605
-					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, ['app' => 'core']);
605
+					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: '.$imagePath, ['app' => 'core']);
606 606
 				}
607 607
 				break;
608 608
 			case IMAGETYPE_BMP:
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 				if (imagetypes() & IMG_WEBP) {
613 613
 					$this->resource = @imagecreatefromwebp($imagePath);
614 614
 				} else {
615
-					$this->logger->debug('OC_Image->loadFromFile, webp images not supported: ' . $imagePath, ['app' => 'core']);
615
+					$this->logger->debug('OC_Image->loadFromFile, webp images not supported: '.$imagePath, ['app' => 'core']);
616 616
 				}
617 617
 				break;
618 618
 			/*
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 */
720 720
 	private function imagecreatefrombmp($fileName) {
721 721
 		if (!($fh = fopen($fileName, 'rb'))) {
722
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, ['app' => 'core']);
722
+			$this->logger->warning('imagecreatefrombmp: Can not open '.$fileName, ['app' => 'core']);
723 723
 			return false;
724 724
 		}
725 725
 		// read file header
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 		// check for bitmap
728 728
 		if ($meta['type'] != 19778) {
729 729
 			fclose($fh);
730
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', ['app' => 'core']);
730
+			$this->logger->warning('imagecreatefrombmp: Can not open '.$fileName.' is not a bitmap!', ['app' => 'core']);
731 731
 			return false;
732 732
 		}
733 733
 		// read image header
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 				$meta['imagesize'] = @filesize($fileName) - $meta['offset'];
752 752
 				if ($meta['imagesize'] < 1) {
753 753
 					fclose($fh);
754
-					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', ['app' => 'core']);
754
+					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of '.$fileName.' is not a bitmap!', ['app' => 'core']);
755 755
 					return false;
756 756
 				}
757 757
 			}
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		// read color palette
762 762
 		$palette = [];
763 763
 		if ($meta['bits'] < 16) {
764
-			$palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4));
764
+			$palette = unpack('l'.$meta['colors'], fread($fh, $meta['colors'] * 4));
765 765
 			// in rare cases the color value is signed
766 766
 			if ($palette[1] < 0) {
767 767
 				foreach ($palette as $i => $color) {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		if ($im == false) {
775 775
 			fclose($fh);
776 776
 			$this->logger->warning(
777
-				'imagecreatefrombmp: imagecreatetruecolor failed for file "' . $fileName . '" with dimensions ' . $meta['width'] . 'x' . $meta['height'],
777
+				'imagecreatefrombmp: imagecreatetruecolor failed for file "'.$fileName.'" with dimensions '.$meta['width'].'x'.$meta['height'],
778 778
 				['app' => 'core']);
779 779
 			return false;
780 780
 		}
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 		$p = 0;
784 784
 		$vide = chr(0);
785 785
 		$y = $meta['height'] - 1;
786
-		$error = 'imagecreatefrombmp: ' . $fileName . ' has not enough data!';
786
+		$error = 'imagecreatefrombmp: '.$fileName.' has not enough data!';
787 787
 		// loop through the image data beginning with the lower left corner
788 788
 		while ($y >= 0) {
789 789
 			$x = 0;
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 							$this->logger->warning($error, ['app' => 'core']);
796 796
 							return $im;
797 797
 						}
798
-						$color = @unpack('V', $part . $vide);
798
+						$color = @unpack('V', $part.$vide);
799 799
 						break;
800 800
 					case 16:
801 801
 						if (!($part = substr($data, $p, 2))) {
@@ -807,16 +807,16 @@  discard block
 block discarded – undo
807 807
 						$color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3);
808 808
 						break;
809 809
 					case 8:
810
-						$color = @unpack('n', $vide . ($data[$p] ?? ''));
810
+						$color = @unpack('n', $vide.($data[$p] ?? ''));
811 811
 						$color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1];
812 812
 						break;
813 813
 					case 4:
814
-						$color = @unpack('n', $vide . ($data[floor($p)] ?? ''));
814
+						$color = @unpack('n', $vide.($data[floor($p)] ?? ''));
815 815
 						$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
816 816
 						$color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1];
817 817
 						break;
818 818
 					case 1:
819
-						$color = @unpack('n', $vide . ($data[floor($p)] ?? ''));
819
+						$color = @unpack('n', $vide.($data[floor($p)] ?? ''));
820 820
 						switch (($p * 8) % 8) {
821 821
 							case 0:
822 822
 								$color[1] = $color[1] >> 7;
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 						break;
848 848
 					default:
849 849
 						fclose($fh);
850
-						$this->logger->warning('imagecreatefrombmp: ' . $fileName . ' has ' . $meta['bits'] . ' bits and this is not supported!', ['app' => 'core']);
850
+						$this->logger->warning('imagecreatefrombmp: '.$fileName.' has '.$meta['bits'].' bits and this is not supported!', ['app' => 'core']);
851 851
 						return false;
852 852
 				}
853 853
 				imagesetpixel($im, $x, $y, $color[1]);
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 */
881 881
 	private function resizeNew($maxSize) {
882 882
 		if (!$this->valid()) {
883
-			$this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
883
+			$this->logger->error(__METHOD__.'(): No image loaded', ['app' => 'core']);
884 884
 			return false;
885 885
 		}
886 886
 		$widthOrig = imagesx($this->resource);
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 			$newHeight = $maxSize;
896 896
 		}
897 897
 
898
-		return $this->preciseResizeNew((int)round($newWidth), (int)round($newHeight));
898
+		return $this->preciseResizeNew((int) round($newWidth), (int) round($newHeight));
899 899
 	}
900 900
 
901 901
 	/**
@@ -918,14 +918,14 @@  discard block
 block discarded – undo
918 918
 	 */
919 919
 	public function preciseResizeNew(int $width, int $height) {
920 920
 		if (!$this->valid()) {
921
-			$this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
921
+			$this->logger->error(__METHOD__.'(): No image loaded', ['app' => 'core']);
922 922
 			return false;
923 923
 		}
924 924
 		$widthOrig = imagesx($this->resource);
925 925
 		$heightOrig = imagesy($this->resource);
926 926
 		$process = imagecreatetruecolor($width, $height);
927 927
 		if ($process === false) {
928
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', ['app' => 'core']);
928
+			$this->logger->error(__METHOD__.'(): Error creating true color image', ['app' => 'core']);
929 929
 			return false;
930 930
 		}
931 931
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 
939 939
 		$res = imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
940 940
 		if ($res === false) {
941
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image', ['app' => 'core']);
941
+			$this->logger->error(__METHOD__.'(): Error re-sampling process image', ['app' => 'core']);
942 942
 			imagedestroy($process);
943 943
 			return false;
944 944
 		}
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 
995 995
 		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
996 996
 		if ($process == false) {
997
-			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, ['app' => 'core']);
997
+			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image '.$width.'x'.$height, ['app' => 'core']);
998 998
 			imagedestroy($process);
999 999
 			return false;
1000 1000
 		}
@@ -1030,12 +1030,12 @@  discard block
 block discarded – undo
1030 1030
 	 */
1031 1031
 	public function cropNew(int $x, int $y, int $w, int $h) {
1032 1032
 		if (!$this->valid()) {
1033
-			$this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
1033
+			$this->logger->error(__METHOD__.'(): No image loaded', ['app' => 'core']);
1034 1034
 			return false;
1035 1035
 		}
1036 1036
 		$process = imagecreatetruecolor($w, $h);
1037 1037
 		if ($process == false) {
1038
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', ['app' => 'core']);
1038
+			$this->logger->error(__METHOD__.'(): Error creating true color image', ['app' => 'core']);
1039 1039
 			imagedestroy($process);
1040 1040
 			return false;
1041 1041
 		}
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
 		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $w, $h, $w, $h);
1051 1051
 		if ($process == false) {
1052
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, ['app' => 'core']);
1052
+			$this->logger->error(__METHOD__.'(): Error re-sampling process image '.$w.'x'.$h, ['app' => 'core']);
1053 1053
 			imagedestroy($process);
1054 1054
 			return false;
1055 1055
 		}
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 	 */
1068 1068
 	public function fitIn($maxWidth, $maxHeight) {
1069 1069
 		if (!$this->valid()) {
1070
-			$this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
1070
+			$this->logger->error(__METHOD__.'(): No image loaded', ['app' => 'core']);
1071 1071
 			return false;
1072 1072
 		}
1073 1073
 		$widthOrig = imagesx($this->resource);
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 		$newWidth = min($maxWidth, $ratio * $maxHeight);
1078 1078
 		$newHeight = min($maxHeight, $maxWidth / $ratio);
1079 1079
 
1080
-		$this->preciseResize((int)round($newWidth), (int)round($newHeight));
1080
+		$this->preciseResize((int) round($newWidth), (int) round($newHeight));
1081 1081
 		return true;
1082 1082
 	}
1083 1083
 
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	 */
1091 1091
 	public function scaleDownToFit($maxWidth, $maxHeight) {
1092 1092
 		if (!$this->valid()) {
1093
-			$this->logger->error(__METHOD__ . '(): No image loaded', ['app' => 'core']);
1093
+			$this->logger->error(__METHOD__.'(): No image loaded', ['app' => 'core']);
1094 1094
 			return false;
1095 1095
 		}
1096 1096
 		$widthOrig = imagesx($this->resource);
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		} elseif ($bit == 32) {
1197 1197
 			$bit = 24;
1198 1198
 		}
1199
-		$bits = (int)pow(2, $bit);
1199
+		$bits = (int) pow(2, $bit);
1200 1200
 		imagetruecolortopalette($im, true, $bits);
1201 1201
 		$width = imagesx($im);
1202 1202
 		$height = imagesy($im);
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 		if ($bit <= 8) {
1206 1206
 			for ($i = 0; $i < $colorsNum; $i++) {
1207 1207
 				$colors = imagecolorsforindex($im, $i);
1208
-				$rgbQuad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . "\0";
1208
+				$rgbQuad .= chr($colors['blue']).chr($colors['green']).chr($colors['red'])."\0";
1209 1209
 			}
1210 1210
 			$bmpData = '';
1211 1211
 			if ($compression == 0 || $bit < 8) {
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 						$index = imagecolorat($im, $i, $j);
1239 1239
 						if ($index !== $lastIndex || $sameNum > 255) {
1240 1240
 							if ($sameNum != 0) {
1241
-								$bmpData .= chr($sameNum) . chr($lastIndex);
1241
+								$bmpData .= chr($sameNum).chr($lastIndex);
1242 1242
 							}
1243 1243
 							$lastIndex = $index;
1244 1244
 							$sameNum = 1;
@@ -1279,15 +1279,15 @@  discard block
 block discarded – undo
1279 1279
 			$sizeData = strlen($bmpData);
1280 1280
 			$colorsNum = 0;
1281 1281
 		}
1282
-		$fileHeader = 'BM' . pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1282
+		$fileHeader = 'BM'.pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1283 1283
 		$infoHeader = pack('V3v2V*', 0x28, $width, $height, 1, $bit, $compression, $sizeData, 0, 0, $colorsNum, 0);
1284 1284
 		if ($fileName != '') {
1285 1285
 			$fp = fopen($fileName, 'wb');
1286
-			fwrite($fp, $fileHeader . $infoHeader . $rgbQuad . $bmpData);
1286
+			fwrite($fp, $fileHeader.$infoHeader.$rgbQuad.$bmpData);
1287 1287
 			fclose($fp);
1288 1288
 			return true;
1289 1289
 		}
1290
-		echo $fileHeader . $infoHeader . $rgbQuad . $bmpData;
1290
+		echo $fileHeader.$infoHeader.$rgbQuad.$bmpData;
1291 1291
 		return true;
1292 1292
 	}
1293 1293
 }
Please login to merge, or discard this patch.