Passed
Push — master ( d22ab5...618873 )
by Roeland
16:32 queued 07:49
created
lib/private/legacy/image.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 */
134 134
 	public function widthTopLeft() {
135 135
 		$o = $this->getOrientation();
136
-		$this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, array('app' => 'core'));
136
+		$this->logger->debug('OC_Image->widthTopLeft() Orientation: '.$o, array('app' => 'core'));
137 137
 		switch ($o) {
138 138
 			case -1:
139 139
 			case 1:
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 */
158 158
 	public function heightTopLeft() {
159 159
 		$o = $this->getOrientation();
160
-		$this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, array('app' => 'core'));
160
+		$this->logger->debug('OC_Image->heightTopLeft() Orientation: '.$o, array('app' => 'core'));
161 161
 		switch ($o) {
162 162
 			case -1:
163 163
 			case 1:
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		if ($mimeType === null) {
185 185
 			$mimeType = $this->mimeType();
186 186
 		}
187
-		header('Content-Type: ' . $mimeType);
187
+		header('Content-Type: '.$mimeType);
188 188
 		return $this->_output(null, $mimeType);
189 189
 	}
190 190
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 		if ($filePath === null) {
204 204
 			if ($this->filePath === null) {
205
-				$this->logger->error(__METHOD__ . '(): called with no path.', array('app' => 'core'));
205
+				$this->logger->error(__METHOD__.'(): called with no path.', array('app' => 'core'));
206 206
 				return false;
207 207
 			} else {
208 208
 				$filePath = $this->filePath;
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 			}
227 227
 			$isWritable = is_writable(dirname($filePath));
228 228
 			if (!$isWritable) {
229
-				$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', array('app' => 'core'));
229
+				$this->logger->error(__METHOD__.'(): Directory \''.dirname($filePath).'\' is not writable.', array('app' => 'core'));
230 230
 				return false;
231 231
 			} elseif ($isWritable && file_exists($filePath) && !is_writable($filePath)) {
232
-				$this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', array('app' => 'core'));
232
+				$this->logger->error(__METHOD__.'(): File \''.$filePath.'\' is not writable.', array('app' => 'core'));
233 233
 				return false;
234 234
 			}
235 235
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 					$imageType = IMAGETYPE_BMP;
258 258
 					break;
259 259
 				default:
260
-					throw new Exception('\OC_Image::_output(): "' . $mimeType . '" is not supported when forcing a specific output format');
260
+					throw new Exception('\OC_Image::_output(): "'.$mimeType.'" is not supported when forcing a specific output format');
261 261
 			}
262 262
 		}
263 263
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 			return;
437 437
 		}
438 438
 
439
-		$exif = @exif_read_data('data://image/jpeg;base64,' . base64_encode($data));
439
+		$exif = @exif_read_data('data://image/jpeg;base64,'.base64_encode($data));
440 440
 		if (!$exif) {
441 441
 			return;
442 442
 		}
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	public function fixOrientation() {
456 456
 		$o = $this->getOrientation();
457
-		$this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core'));
457
+		$this->logger->debug('OC_Image->fixOrientation() Orientation: '.$o, array('app' => 'core'));
458 458
 		$rotate = 0;
459 459
 		$flip = false;
460 460
 		switch ($o) {
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 				$rotate = 90;
490 490
 				break;
491 491
 		}
492
-		if($flip && function_exists('imageflip')) {
492
+		if ($flip && function_exists('imageflip')) {
493 493
 			imageflip($this->resource, IMG_FLIP_HORIZONTAL);
494 494
 		}
495 495
 		if ($rotate) {
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 					imagealphablending($this->resource, true);
552 552
 					imagesavealpha($this->resource, true);
553 553
 				} else {
554
-					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: ' . $imagePath, array('app' => 'core'));
554
+					$this->logger->debug('OC_Image->loadFromFile, GIF images not supported: '.$imagePath, array('app' => 'core'));
555 555
 				}
556 556
 				break;
557 557
 			case IMAGETYPE_JPEG:
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
 					if (getimagesize($imagePath) !== false) {
560 560
 						$this->resource = @imagecreatefromjpeg($imagePath);
561 561
 					} else {
562
-						$this->logger->debug('OC_Image->loadFromFile, JPG image not valid: ' . $imagePath, array('app' => 'core'));
562
+						$this->logger->debug('OC_Image->loadFromFile, JPG image not valid: '.$imagePath, array('app' => 'core'));
563 563
 					}
564 564
 				} else {
565
-					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: ' . $imagePath, array('app' => 'core'));
565
+					$this->logger->debug('OC_Image->loadFromFile, JPG images not supported: '.$imagePath, array('app' => 'core'));
566 566
 				}
567 567
 				break;
568 568
 			case IMAGETYPE_PNG:
@@ -572,21 +572,21 @@  discard block
 block discarded – undo
572 572
 					imagealphablending($this->resource, true);
573 573
 					imagesavealpha($this->resource, true);
574 574
 				} else {
575
-					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: ' . $imagePath, array('app' => 'core'));
575
+					$this->logger->debug('OC_Image->loadFromFile, PNG images not supported: '.$imagePath, array('app' => 'core'));
576 576
 				}
577 577
 				break;
578 578
 			case IMAGETYPE_XBM:
579 579
 				if (imagetypes() & IMG_XPM) {
580 580
 					$this->resource = @imagecreatefromxbm($imagePath);
581 581
 				} else {
582
-					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: ' . $imagePath, array('app' => 'core'));
582
+					$this->logger->debug('OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagePath, array('app' => 'core'));
583 583
 				}
584 584
 				break;
585 585
 			case IMAGETYPE_WBMP:
586 586
 				if (imagetypes() & IMG_WBMP) {
587 587
 					$this->resource = @imagecreatefromwbmp($imagePath);
588 588
 				} else {
589
-					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, array('app' => 'core'));
589
+					$this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: '.$imagePath, array('app' => 'core'));
590 590
 				}
591 591
 				break;
592 592
 			case IMAGETYPE_BMP:
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 */
697 697
 	private function imagecreatefrombmp($fileName) {
698 698
 		if (!($fh = fopen($fileName, 'rb'))) {
699
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, array('app' => 'core'));
699
+			$this->logger->warning('imagecreatefrombmp: Can not open '.$fileName, array('app' => 'core'));
700 700
 			return false;
701 701
 		}
702 702
 		// read file header
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		// check for bitmap
705 705
 		if ($meta['type'] != 19778) {
706 706
 			fclose($fh);
707
-			$this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
707
+			$this->logger->warning('imagecreatefrombmp: Can not open '.$fileName.' is not a bitmap!', array('app' => 'core'));
708 708
 			return false;
709 709
 		}
710 710
 		// read image header
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 				$meta['imagesize'] = @filesize($fileName) - $meta['offset'];
729 729
 				if ($meta['imagesize'] < 1) {
730 730
 					fclose($fh);
731
-					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', array('app' => 'core'));
731
+					$this->logger->warning('imagecreatefrombmp: Can not obtain file size of '.$fileName.' is not a bitmap!', array('app' => 'core'));
732 732
 					return false;
733 733
 				}
734 734
 			}
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 		// read color palette
739 739
 		$palette = array();
740 740
 		if ($meta['bits'] < 16) {
741
-			$palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4));
741
+			$palette = unpack('l'.$meta['colors'], fread($fh, $meta['colors'] * 4));
742 742
 			// in rare cases the color value is signed
743 743
 			if ($palette[1] < 0) {
744 744
 				foreach ($palette as $i => $color) {
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 		if ($im == false) {
752 752
 			fclose($fh);
753 753
 			$this->logger->warning(
754
-				'imagecreatefrombmp: imagecreatetruecolor failed for file "' . $fileName . '" with dimensions ' . $meta['width'] . 'x' . $meta['height'],
754
+				'imagecreatefrombmp: imagecreatetruecolor failed for file "'.$fileName.'" with dimensions '.$meta['width'].'x'.$meta['height'],
755 755
 				array('app' => 'core'));
756 756
 			return false;
757 757
 		}
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 		$p = 0;
761 761
 		$vide = chr(0);
762 762
 		$y = $meta['height'] - 1;
763
-		$error = 'imagecreatefrombmp: ' . $fileName . ' has not enough data!';
763
+		$error = 'imagecreatefrombmp: '.$fileName.' has not enough data!';
764 764
 		// loop through the image data beginning with the lower left corner
765 765
 		while ($y >= 0) {
766 766
 			$x = 0;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 							$this->logger->warning($error, array('app' => 'core'));
773 773
 							return $im;
774 774
 						}
775
-						$color = @unpack('V', $part . $vide);
775
+						$color = @unpack('V', $part.$vide);
776 776
 						break;
777 777
 					case 16:
778 778
 						if (!($part = substr($data, $p, 2))) {
@@ -784,16 +784,16 @@  discard block
 block discarded – undo
784 784
 						$color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3);
785 785
 						break;
786 786
 					case 8:
787
-						$color = @unpack('n', $vide . ($data[$p] ?? ''));
787
+						$color = @unpack('n', $vide.($data[$p] ?? ''));
788 788
 						$color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1];
789 789
 						break;
790 790
 					case 4:
791
-						$color = @unpack('n', $vide . ($data[floor($p)] ?? ''));
791
+						$color = @unpack('n', $vide.($data[floor($p)] ?? ''));
792 792
 						$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F;
793 793
 						$color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1];
794 794
 						break;
795 795
 					case 1:
796
-						$color = @unpack('n', $vide . ($data[floor($p)] ?? ''));
796
+						$color = @unpack('n', $vide.($data[floor($p)] ?? ''));
797 797
 						switch (($p * 8) % 8) {
798 798
 							case 0:
799 799
 								$color[1] = $color[1] >> 7;
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 						break;
825 825
 					default:
826 826
 						fclose($fh);
827
-						$this->logger->warning('imagecreatefrombmp: ' . $fileName . ' has ' . $meta['bits'] . ' bits and this is not supported!', array('app' => 'core'));
827
+						$this->logger->warning('imagecreatefrombmp: '.$fileName.' has '.$meta['bits'].' bits and this is not supported!', array('app' => 'core'));
828 828
 						return false;
829 829
 				}
830 830
 				imagesetpixel($im, $x, $y, $color[1]);
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 	 */
847 847
 	public function resize($maxSize) {
848 848
 		if (!$this->valid()) {
849
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
849
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
850 850
 			return false;
851 851
 		}
852 852
 		$widthOrig = imagesx($this->resource);
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 			$newHeight = $maxSize;
862 862
 		}
863 863
 
864
-		$this->preciseResize((int)round($newWidth), (int)round($newHeight));
864
+		$this->preciseResize((int) round($newWidth), (int) round($newHeight));
865 865
 		return true;
866 866
 	}
867 867
 
@@ -872,14 +872,14 @@  discard block
 block discarded – undo
872 872
 	 */
873 873
 	public function preciseResize(int $width, int $height): bool {
874 874
 		if (!$this->valid()) {
875
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
875
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
876 876
 			return false;
877 877
 		}
878 878
 		$widthOrig = imagesx($this->resource);
879 879
 		$heightOrig = imagesy($this->resource);
880 880
 		$process = imagecreatetruecolor($width, $height);
881 881
 		if ($process === false) {
882
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
882
+			$this->logger->error(__METHOD__.'(): Error creating true color image', array('app' => 'core'));
883 883
 			return false;
884 884
 		}
885 885
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 
893 893
 		$res = imagecopyresampled($process, $this->resource, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);
894 894
 		if ($res === false) {
895
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image', array('app' => 'core'));
895
+			$this->logger->error(__METHOD__.'(): Error re-sampling process image', array('app' => 'core'));
896 896
 			imagedestroy($process);
897 897
 			return false;
898 898
 		}
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 
951 951
 		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
952 952
 		if ($process == false) {
953
-			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image ' . $width . 'x' . $height, array('app' => 'core'));
953
+			$this->logger->error('OC_Image->centerCrop, Error re-sampling process image '.$width.'x'.$height, array('app' => 'core'));
954 954
 			imagedestroy($process);
955 955
 			return false;
956 956
 		}
@@ -970,12 +970,12 @@  discard block
 block discarded – undo
970 970
 	 */
971 971
 	public function crop(int $x, int $y, int $w, int $h): bool {
972 972
 		if (!$this->valid()) {
973
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
973
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
974 974
 			return false;
975 975
 		}
976 976
 		$process = imagecreatetruecolor($w, $h);
977 977
 		if ($process == false) {
978
-			$this->logger->error(__METHOD__ . '(): Error creating true color image', array('app' => 'core'));
978
+			$this->logger->error(__METHOD__.'(): Error creating true color image', array('app' => 'core'));
979 979
 			imagedestroy($process);
980 980
 			return false;
981 981
 		}
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 
990 990
 		imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $w, $h, $w, $h);
991 991
 		if ($process == false) {
992
-			$this->logger->error(__METHOD__ . '(): Error re-sampling process image ' . $w . 'x' . $h, array('app' => 'core'));
992
+			$this->logger->error(__METHOD__.'(): Error re-sampling process image '.$w.'x'.$h, array('app' => 'core'));
993 993
 			imagedestroy($process);
994 994
 			return false;
995 995
 		}
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 	 */
1010 1010
 	public function fitIn($maxWidth, $maxHeight) {
1011 1011
 		if (!$this->valid()) {
1012
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
1012
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
1013 1013
 			return false;
1014 1014
 		}
1015 1015
 		$widthOrig = imagesx($this->resource);
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 		$newWidth = min($maxWidth, $ratio * $maxHeight);
1020 1020
 		$newHeight = min($maxHeight, $maxWidth / $ratio);
1021 1021
 
1022
-		$this->preciseResize((int)round($newWidth), (int)round($newHeight));
1022
+		$this->preciseResize((int) round($newWidth), (int) round($newHeight));
1023 1023
 		return true;
1024 1024
 	}
1025 1025
 
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 	 */
1033 1033
 	public function scaleDownToFit($maxWidth, $maxHeight) {
1034 1034
 		if (!$this->valid()) {
1035
-			$this->logger->error(__METHOD__ . '(): No image loaded', array('app' => 'core'));
1035
+			$this->logger->error(__METHOD__.'(): No image loaded', array('app' => 'core'));
1036 1036
 			return false;
1037 1037
 		}
1038 1038
 		$widthOrig = imagesx($this->resource);
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 		if ($bit <= 8) {
1091 1091
 			for ($i = 0; $i < $colorsNum; $i++) {
1092 1092
 				$colors = imagecolorsforindex($im, $i);
1093
-				$rgbQuad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . "\0";
1093
+				$rgbQuad .= chr($colors['blue']).chr($colors['green']).chr($colors['red'])."\0";
1094 1094
 			}
1095 1095
 			$bmpData = '';
1096 1096
 			if ($compression == 0 || $bit < 8) {
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 						$index = imagecolorat($im, $i, $j);
1124 1124
 						if ($index !== $lastIndex || $sameNum > 255) {
1125 1125
 							if ($sameNum != 0) {
1126
-								$bmpData .= chr($sameNum) . chr($lastIndex);
1126
+								$bmpData .= chr($sameNum).chr($lastIndex);
1127 1127
 							}
1128 1128
 							$lastIndex = $index;
1129 1129
 							$sameNum = 1;
@@ -1164,15 +1164,15 @@  discard block
 block discarded – undo
1164 1164
 			$sizeData = strlen($bmpData);
1165 1165
 			$colorsNum = 0;
1166 1166
 		}
1167
-		$fileHeader = 'BM' . pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1167
+		$fileHeader = 'BM'.pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad);
1168 1168
 		$infoHeader = pack('V3v2V*', 0x28, $width, $height, 1, $bit, $compression, $sizeData, 0, 0, $colorsNum, 0);
1169 1169
 		if ($fileName != '') {
1170 1170
 			$fp = fopen($fileName, 'wb');
1171
-			fwrite($fp, $fileHeader . $infoHeader . $rgbQuad . $bmpData);
1171
+			fwrite($fp, $fileHeader.$infoHeader.$rgbQuad.$bmpData);
1172 1172
 			fclose($fp);
1173 1173
 			return true;
1174 1174
 		}
1175
-		echo $fileHeader . $infoHeader . $rgbQuad . $bmpData;
1175
+		echo $fileHeader.$infoHeader.$rgbQuad.$bmpData;
1176 1176
 		return true;
1177 1177
 	}
1178 1178
 }
Please login to merge, or discard this patch.