count($obd_values) > 0
- null|string
- $data[floor($p)]
- $data[floor($p)]
- $this->bitDepth
- $x
- $y
- $isWritable
- \Test\Util\User\Dummy
diff --git a/lib/private/StreamImage.php b/lib/private/StreamImage.php
index 38fd114df17e5..33078310d279e 100644
--- a/lib/private/StreamImage.php
+++ b/lib/private/StreamImage.php
@@ -37,7 +37,7 @@ class StreamImage implements IStreamImage {
/** @var resource The internal stream */
private $stream;
- /** @var string */
+ /** @var null|string */
private $mimeType;
/** @var int */
@@ -55,38 +55,38 @@ public function __construct($stream, string $mimeType, int $width, int $height)
}
/** @inheritDoc */
- public function valid() {
+ public function valid(): bool {
return is_resource($this->stream);
}
/** @inheritDoc */
- public function mimeType() {
+ public function mimeType(): ?string {
return $this->mimeType;
}
/** @inheritDoc */
- public function width() {
+ public function width(): int {
return $this->width;
}
/** @inheritDoc */
- public function height() {
+ public function height(): int {
return $this->height;
}
- public function widthTopLeft() {
+ public function widthTopLeft(): int {
throw new \BadMethodCallException('Not implemented');
}
- public function heightTopLeft() {
+ public function heightTopLeft(): int {
throw new \BadMethodCallException('Not implemented');
}
- public function show($mimeType = null) {
+ public function show(?string $mimeType = null): bool {
throw new \BadMethodCallException('Not implemented');
}
- public function save($filePath = null, $mimeType = null) {
+ public function save(?string $filePath = null, ?string $mimeType = null): bool {
throw new \BadMethodCallException('Not implemented');
}
@@ -94,23 +94,23 @@ public function resource() {
return $this->stream;
}
- public function dataMimeType() {
+ public function dataMimeType(): ?string {
return $this->mimeType;
}
- public function data() {
+ public function data(): ?string {
return '';
}
- public function getOrientation() {
+ public function getOrientation(): int {
throw new \BadMethodCallException('Not implemented');
}
- public function fixOrientation() {
+ public function fixOrientation(): bool {
throw new \BadMethodCallException('Not implemented');
}
- public function resize($maxSize) {
+ public function resize(int $maxSize): bool {
throw new \BadMethodCallException('Not implemented');
}
@@ -118,7 +118,7 @@ public function preciseResize(int $width, int $height): bool {
throw new \BadMethodCallException('Not implemented');
}
- public function centerCrop($size = 0) {
+ public function centerCrop(int $size = 0): bool {
throw new \BadMethodCallException('Not implemented');
}
@@ -126,11 +126,11 @@ public function crop(int $x, int $y, int $w, int $h): bool {
throw new \BadMethodCallException('Not implemented');
}
- public function fitIn($maxWidth, $maxHeight) {
+ public function fitIn(int $maxWidth, int $maxHeight): bool {
throw new \BadMethodCallException('Not implemented');
}
- public function scaleDownToFit($maxWidth, $maxHeight) {
+ public function scaleDownToFit(int $maxWidth, int $maxHeight): bool {
throw new \BadMethodCallException('Not implemented');
}
diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php
index b48d13c4d5b9a..9ccc6409ba030 100644
--- a/lib/private/legacy/OC_Image.php
+++ b/lib/private/legacy/OC_Image.php
@@ -1,4 +1,7 @@
resource) && get_resource_type($this->resource) === 'gd') ||
(is_object($this->resource) && get_class($this->resource) === \GdImage::class)) {
return true;
@@ -112,12 +116,12 @@ public function valid() {
}
/**
- * Returns the MIME type of the image or an empty string if no image is loaded.
+ * Returns the MIME type of the image or null if no image is loaded.
*
* @return string
*/
- public function mimeType() {
- return $this->valid() ? $this->mimeType : '';
+ public function mimeType(): ?string {
+ return $this->valid() ? $this->mimeType : null;
}
/**
@@ -125,7 +129,7 @@ public function mimeType() {
*
* @return int
*/
- public function width() {
+ public function width(): int {
if ($this->valid()) {
$width = imagesx($this->resource);
if ($width !== false) {
@@ -140,7 +144,7 @@ public function width() {
*
* @return int
*/
- public function height() {
+ public function height(): int {
if ($this->valid()) {
$height = imagesy($this->resource);
if ($height !== false) {
@@ -155,7 +159,7 @@ public function height() {
*
* @return int
*/
- public function widthTopLeft() {
+ public function widthTopLeft(): int {
$o = $this->getOrientation();
$this->logger->debug('OC_Image->widthTopLeft() Orientation: ' . $o, ['app' => 'core']);
switch ($o) {
@@ -179,7 +183,7 @@ public function widthTopLeft() {
*
* @return int
*/
- public function heightTopLeft() {
+ public function heightTopLeft(): int {
$o = $this->getOrientation();
$this->logger->debug('OC_Image->heightTopLeft() Orientation: ' . $o, ['app' => 'core']);
switch ($o) {
@@ -204,7 +208,7 @@ public function heightTopLeft() {
* @param string $mimeType
* @return bool
*/
- public function show($mimeType = null) {
+ public function show(string $mimeType = null): bool {
if ($mimeType === null) {
$mimeType = $this->mimeType();
}
@@ -220,7 +224,7 @@ public function show($mimeType = null) {
* @return bool
*/
- public function save($filePath = null, $mimeType = null) {
+ public function save(?string $filePath = null, ?string $mimeType = null): bool {
if ($mimeType === null) {
$mimeType = $this->mimeType();
}
@@ -243,7 +247,7 @@ public function save($filePath = null, $mimeType = null) {
* @return bool
* @throws Exception
*/
- private function _output($filePath = null, $mimeType = null) {
+ private function _output(?string $filePath = null, ?string $mimeType = null): bool {
if ($filePath) {
if (!file_exists(dirname($filePath))) {
mkdir(dirname($filePath), 0777, true);
@@ -252,7 +256,7 @@ private function _output($filePath = null, $mimeType = null) {
if (!$isWritable) {
$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', ['app' => 'core']);
return false;
- } elseif ($isWritable && file_exists($filePath) && !is_writable($filePath)) {
+ } elseif (file_exists($filePath) && !is_writable($filePath)) {
$this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', ['app' => 'core']);
return false;
}
@@ -309,7 +313,7 @@ private function _output($filePath = null, $mimeType = null) {
$retVal = imagewbmp($this->resource, $filePath);
break;
case IMAGETYPE_BMP:
- $retVal = imagebmp($this->resource, $filePath, $this->bitDepth);
+ $retVal = imagebmp($this->resource, $filePath);
break;
default:
$retVal = imagepng($this->resource, $filePath);
@@ -350,12 +354,11 @@ public function resource() {
}
/**
- * @return string Returns the mimetype of the data. Returns the empty string
- * if the data is not valid.
+ * @return string Returns the mimetype of the data. Returns null if the data is not valid.
*/
- public function dataMimeType() {
+ public function dataMimeType(): ?string {
if (!$this->valid()) {
- return '';
+ return null;
}
switch ($this->mimeType) {
@@ -371,7 +374,7 @@ public function dataMimeType() {
/**
* @return null|string Returns the raw image data.
*/
- public function data() {
+ public function data(): ?string {
if (!$this->valid()) {
return null;
}
@@ -384,11 +387,7 @@ public function data() {
/** @psalm-suppress InvalidScalarArgument */
imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1));
$quality = $this->getJpegQuality();
- if ($quality !== null) {
- $res = imagejpeg($this->resource, null, $quality);
- } else {
- $res = imagejpeg($this->resource);
- }
+ $res = imagejpeg($this->resource, null, $quality);
break;
case "image/gif":
$res = imagegif($this->resource);
@@ -412,14 +411,15 @@ public function __toString() {
}
/**
- * @return int|null
+ * @return int
*/
- protected function getJpegQuality() {
- $quality = $this->config->getAppValue('preview', 'jpeg_quality', '80');
- if ($quality !== null) {
- $quality = min(100, max(10, (int) $quality));
+ protected function getJpegQuality(): int {
+ $quality = $this->config->getAppValue('preview', 'jpeg_quality', (string) self::DEFAULT_JPEG_QUALITY);
+ // TODO: remove when getAppValue is type safe
+ if ($quality === null) {
+ $quality = self::DEFAULT_JPEG_QUALITY;
}
- return $quality;
+ return min(100, max(10, (int) $quality));
}
/**
@@ -428,7 +428,7 @@ protected function getJpegQuality() {
*
* @return int The orientation or -1 if no EXIF data is available.
*/
- public function getOrientation() {
+ public function getOrientation(): int {
if ($this->exif !== null) {
return $this->exif['Orientation'];
}
@@ -460,7 +460,7 @@ public function getOrientation() {
return $exif['Orientation'];
}
- public function readExif($data) {
+ public function readExif($data): void {
if (!is_callable('exif_read_data')) {
$this->logger->debug('OC_Image->fixOrientation() Exif module not enabled.', ['app' => 'core']);
return;
@@ -486,7 +486,7 @@ public function readExif($data) {
*
* @return bool
*/
- public function fixOrientation() {
+ public function fixOrientation(): bool {
if (!$this->valid()) {
$this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']);
return false;
@@ -716,7 +716,7 @@ public function loadFromFile($imagePath = false) {
}
break;
case IMAGETYPE_BMP:
- $this->resource = $this->imagecreatefrombmp($imagePath);
+ $this->resource = imagecreatefrombmp($imagePath);
break;
case IMAGETYPE_WEBP:
if (imagetypes() & IMG_WEBP) {
@@ -778,10 +778,7 @@ public function loadFromFile($imagePath = false) {
* @param string $str A string of image data as read from a file.
* @return bool|resource|\GdImage An image resource or false on error
*/
- public function loadFromData($str) {
- if (!is_string($str)) {
- return false;
- }
+ public function loadFromData(string $str) {
if (!$this->checkImageDataSize($str)) {
return false;
}
@@ -807,10 +804,7 @@ public function loadFromData($str) {
* @param string $str A string base64 encoded string of image data.
* @return bool|resource|\GdImage An image resource or false on error
*/
- public function loadFromBase64($str) {
- if (!is_string($str)) {
- return false;
- }
+ public function loadFromBase64(string $str) {
$data = base64_decode($str);
if ($data) { // try to load from string data
if (!$this->checkImageDataSize($data)) {
@@ -830,171 +824,13 @@ public function loadFromBase64($str) {
}
}
- /**
- * Create a new image from file or URL
- *
- * @link http://www.programmierer-forum.de/function-imagecreatefrombmp-laeuft-mit-allen-bitraten-t143137.htm
- * @version 1.00
- * @param string $fileName - * Path to the BMP image. - *
- * @return bool|resource|\GdImage an image resource identifier on success, FALSE on errors. - */ - private function imagecreatefrombmp($fileName) { - if (!($fh = fopen($fileName, 'rb'))) { - $this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName, ['app' => 'core']); - return false; - } - // read file header - $meta = unpack('vtype/Vfilesize/Vreserved/Voffset', fread($fh, 14)); - // check for bitmap - if ($meta['type'] != 19778) { - fclose($fh); - $this->logger->warning('imagecreatefrombmp: Can not open ' . $fileName . ' is not a bitmap!', ['app' => 'core']); - return false; - } - // read image header - $meta += unpack('Vheadersize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vcolors/Vimportant', fread($fh, 40)); - // read additional 16bit header - if ($meta['bits'] == 16) { - $meta += unpack('VrMask/VgMask/VbMask', fread($fh, 12)); - } - // set bytes and padding - $meta['bytes'] = $meta['bits'] / 8; - $this->bitDepth = $meta['bits']; //remember the bit depth for the imagebmp call - $meta['decal'] = 4 - (4 * (($meta['width'] * $meta['bytes'] / 4) - floor($meta['width'] * $meta['bytes'] / 4))); - if ($meta['decal'] == 4) { - $meta['decal'] = 0; - } - // obtain imagesize - if ($meta['imagesize'] < 1) { - $meta['imagesize'] = $meta['filesize'] - $meta['offset']; - // in rare cases filesize is equal to offset so we need to read physical size - if ($meta['imagesize'] < 1) { - $meta['imagesize'] = @filesize($fileName) - $meta['offset']; - if ($meta['imagesize'] < 1) { - fclose($fh); - $this->logger->warning('imagecreatefrombmp: Can not obtain file size of ' . $fileName . ' is not a bitmap!', ['app' => 'core']); - return false; - } - } - } - // calculate colors - $meta['colors'] = !$meta['colors'] ? pow(2, $meta['bits']) : $meta['colors']; - // read color palette - $palette = []; - if ($meta['bits'] < 16) { - $palette = unpack('l' . $meta['colors'], fread($fh, $meta['colors'] * 4)); - // in rare cases the color value is signed - if ($palette[1] < 0) { - foreach ($palette as $i => $color) { - $palette[$i] = $color + 16777216; - } - } - } - if (!$this->checkImageMemory($meta['width'], $meta['height'])) { - fclose($fh); - return false; - } - // create gd image - $im = imagecreatetruecolor($meta['width'], $meta['height']); - if ($im == false) { - fclose($fh); - $this->logger->warning( - 'imagecreatefrombmp: imagecreatetruecolor failed for file "' . $fileName . '" with dimensions ' . $meta['width'] . 'x' . $meta['height'], - ['app' => 'core']); - return false; - } - - $data = fread($fh, $meta['imagesize']); - $p = 0; - $vide = chr(0); - $y = $meta['height'] - 1; - $error = 'imagecreatefrombmp: ' . $fileName . ' has not enough data!'; - // loop through the image data beginning with the lower left corner - while ($y >= 0) { - $x = 0; - while ($x < $meta['width']) { - switch ($meta['bits']) { - case 32: - case 24: - if (!($part = substr($data, $p, 3))) { - $this->logger->warning($error, ['app' => 'core']); - return $im; - } - $color = @unpack('V', $part . $vide); - break; - case 16: - if (!($part = substr($data, $p, 2))) { - fclose($fh); - $this->logger->warning($error, ['app' => 'core']); - return $im; - } - $color = @unpack('v', $part); - $color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3); - break; - case 8: - $color = @unpack('n', $vide . ($data[$p] ?? '')); - $color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1]; - break; - case 4: - $color = @unpack('n', $vide . ($data[floor($p)] ?? '')); - $color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F; - $color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1]; - break; - case 1: - $color = @unpack('n', $vide . ($data[floor($p)] ?? '')); - switch (($p * 8) % 8) { - case 0: - $color[1] = $color[1] >> 7; - break; - case 1: - $color[1] = ($color[1] & 0x40) >> 6; - break; - case 2: - $color[1] = ($color[1] & 0x20) >> 5; - break; - case 3: - $color[1] = ($color[1] & 0x10) >> 4; - break; - case 4: - $color[1] = ($color[1] & 0x8) >> 3; - break; - case 5: - $color[1] = ($color[1] & 0x4) >> 2; - break; - case 6: - $color[1] = ($color[1] & 0x2) >> 1; - break; - case 7: - $color[1] = ($color[1] & 0x1); - break; - } - $color[1] = isset($palette[$color[1] + 1]) ? $palette[$color[1] + 1] : $palette[1]; - break; - default: - fclose($fh); - $this->logger->warning('imagecreatefrombmp: ' . $fileName . ' has ' . $meta['bits'] . ' bits and this is not supported!', ['app' => 'core']); - return false; - } - imagesetpixel($im, $x, $y, $color[1]); - $x++; - $p += $meta['bytes']; - } - $y--; - $p += $meta['decal']; - } - fclose($fh); - return $im; - } - /** * Resizes the image preserving ratio. * - * @param integer $maxSize The maximum size of either the width or height. + * @param int $maxSize The maximum size of either the width or height. * @return bool */ - public function resize($maxSize) { + public function resize(int $maxSize): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); return false; @@ -1009,7 +845,7 @@ public function resize($maxSize) { * @param $maxSize * @return resource|bool|\GdImage */ - private function resizeNew($maxSize) { + private function resizeNew(int $maxSize) { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); return false; @@ -1045,7 +881,6 @@ public function preciseResize(int $width, int $height): bool { return $this->valid(); } - /** * @param int $width * @param int $height @@ -1090,7 +925,7 @@ public function preciseResizeNew(int $width, int $height) { * @param int $size maximum size for the result (optional) * @return bool for success or failure */ - public function centerCrop($size = 0) { + public function centerCrop(int $size = 0): bool { if (!$this->valid()) { $this->logger->debug('OC_Image->centerCrop, No image loaded', ['app' => 'core']); return false; @@ -1104,10 +939,10 @@ public function centerCrop($size = 0) { $width = $height = min($widthOrig, $heightOrig); if ($ratioOrig > 1) { - $x = ($widthOrig / 2) - ($width / 2); + $x = (int) (($widthOrig / 2) - ($width / 2)); $y = 0; } else { - $y = ($heightOrig / 2) - ($height / 2); + $y = (int) (($heightOrig / 2) - ($height / 2)); $x = 0; } if ($size > 0) { @@ -1200,11 +1035,11 @@ public function cropNew(int $x, int $y, int $w, int $h) { * * Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up * - * @param integer $maxWidth - * @param integer $maxHeight + * @param int $maxWidth + * @param int $maxHeight * @return bool */ - public function fitIn($maxWidth, $maxHeight) { + public function fitIn(int $maxWidth, int $maxHeight): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); return false; @@ -1223,11 +1058,11 @@ public function fitIn($maxWidth, $maxHeight) { /** * Shrinks larger images to fit within specified boundaries while preserving ratio. * - * @param integer $maxWidth - * @param integer $maxHeight + * @param int $maxWidth + * @param int $maxHeight * @return bool */ - public function scaleDownToFit($maxWidth, $maxHeight) { + public function scaleDownToFit(int $maxWidth, int $maxHeight): bool { if (!$this->valid()) { $this->logger->debug(__METHOD__ . '(): No image loaded', ['app' => 'core']); return false; @@ -1263,7 +1098,6 @@ public function cropCopy(int $x, int $y, int $w, int $h): IImage { $image = new OC_Image(null, $this->logger, $this->config); $image->imageType = $this->imageType; $image->mimeType = $this->mimeType; - $image->bitDepth = $this->bitDepth; $image->resource = $this->cropNew($x, $y, $w, $h); return $image; @@ -1273,7 +1107,6 @@ public function preciseResizeCopy(int $width, int $height): IImage { $image = new OC_Image(null, $this->logger, $this->config); $image->imageType = $this->imageType; $image->mimeType = $this->mimeType; - $image->bitDepth = $this->bitDepth; $image->resource = $this->preciseResizeNew($width, $height); return $image; @@ -1283,7 +1116,6 @@ public function resizeCopy(int $maxSize): IImage { $image = new OC_Image(null, $this->logger, $this->config); $image->imageType = $this->imageType; $image->mimeType = $this->mimeType; - $image->bitDepth = $this->bitDepth; $image->resource = $this->resizeNew($maxSize); return $image; @@ -1292,7 +1124,7 @@ public function resizeCopy(int $maxSize): IImage { /** * Destroys the current image and resets the object */ - public function destroy() { + public function destroy(): void { if ($this->valid()) { imagedestroy($this->resource); } @@ -1304,123 +1136,6 @@ public function __destruct() { } } -if (!function_exists('imagebmp')) { - /** - * Output a BMP image to either the browser or a file - * - * @link http://www.ugia.cn/wp-data/imagebmp.php - * @author legendThe path to save the file to.
- * @param int $bit [optional]Bit depth, (default is 24).
- * @param int $compression [optional] - * @return bool TRUE on success or FALSE on failure. - */ - function imagebmp($im, $fileName = '', $bit = 24, $compression = 0) { - if (!in_array($bit, [1, 4, 8, 16, 24, 32])) { - $bit = 24; - } elseif ($bit == 32) { - $bit = 24; - } - $bits = (int)pow(2, $bit); - imagetruecolortopalette($im, true, $bits); - $width = imagesx($im); - $height = imagesy($im); - $colorsNum = imagecolorstotal($im); - $rgbQuad = ''; - if ($bit <= 8) { - for ($i = 0; $i < $colorsNum; $i++) { - $colors = imagecolorsforindex($im, $i); - $rgbQuad .= chr($colors['blue']) . chr($colors['green']) . chr($colors['red']) . "\0"; - } - $bmpData = ''; - if ($compression == 0 || $bit < 8) { - $compression = 0; - $extra = ''; - $padding = 4 - ceil($width / (8 / $bit)) % 4; - if ($padding % 4 != 0) { - $extra = str_repeat("\0", $padding); - } - for ($j = $height - 1; $j >= 0; $j--) { - $i = 0; - while ($i < $width) { - $bin = 0; - $limit = $width - $i < 8 / $bit ? (8 / $bit - $width + $i) * $bit : 0; - for ($k = 8 - $bit; $k >= $limit; $k -= $bit) { - $index = imagecolorat($im, $i, $j); - $bin |= $index << $k; - $i++; - } - $bmpData .= chr($bin); - } - $bmpData .= $extra; - } - } // RLE8 - elseif ($compression == 1 && $bit == 8) { - for ($j = $height - 1; $j >= 0; $j--) { - $lastIndex = null; - $sameNum = 0; - for ($i = 0; $i <= $width; $i++) { - $index = imagecolorat($im, $i, $j); - if ($index !== $lastIndex || $sameNum > 255) { - if ($sameNum != 0) { - $bmpData .= chr($sameNum) . chr($lastIndex); - } - $lastIndex = $index; - $sameNum = 1; - } else { - $sameNum++; - } - } - $bmpData .= "\0\0"; - } - $bmpData .= "\0\1"; - } - $sizeQuad = strlen($rgbQuad); - $sizeData = strlen($bmpData); - } else { - $extra = ''; - $padding = 4 - ($width * ($bit / 8)) % 4; - if ($padding % 4 != 0) { - $extra = str_repeat("\0", $padding); - } - $bmpData = ''; - for ($j = $height - 1; $j >= 0; $j--) { - for ($i = 0; $i < $width; $i++) { - $index = imagecolorat($im, $i, $j); - $colors = imagecolorsforindex($im, $index); - if ($bit == 16) { - $bin = 0 << $bit; - $bin |= ($colors['red'] >> 3) << 10; - $bin |= ($colors['green'] >> 3) << 5; - $bin |= $colors['blue'] >> 3; - $bmpData .= pack("v", $bin); - } else { - $bmpData .= pack("c*", $colors['blue'], $colors['green'], $colors['red']); - } - } - $bmpData .= $extra; - } - $sizeQuad = 0; - $sizeData = strlen($bmpData); - $colorsNum = 0; - } - $fileHeader = 'BM' . pack('V3', 54 + $sizeQuad + $sizeData, 0, 54 + $sizeQuad); - $infoHeader = pack('V3v2V*', 0x28, $width, $height, 1, $bit, $compression, $sizeData, 0, 0, $colorsNum, 0); - if ($fileName != '') { - $fp = fopen($fileName, 'wb'); - fwrite($fp, $fileHeader . $infoHeader . $rgbQuad . $bmpData); - fclose($fp); - return true; - } - echo $fileHeader . $infoHeader . $rgbQuad . $bmpData; - return true; - } -} - if (!function_exists('exif_imagetype')) { /** * Workaround if exif_imagetype does not exist @@ -1429,7 +1144,7 @@ function imagebmp($im, $fileName = '', $bit = 24, $compression = 0) { * @param string $fileName * @return string|boolean */ - function exif_imagetype($fileName) { + function exif_imagetype(string $fileName) { if (($info = getimagesize($fileName)) !== false) { return $info[2]; } diff --git a/lib/public/IImage.php b/lib/public/IImage.php index 659cd24720d7c..f1ac3bf1a5011 100644 --- a/lib/public/IImage.php +++ b/lib/public/IImage.php @@ -1,4 +1,7 @@ = 80000 ? true : 1)); ob_start(); - imagejpeg($raw); + imagejpeg($raw, null, 80); $expected = ob_get_clean(); $this->assertEquals($expected, $img->data());