From 57c66bf7cb772d5d6d7a17f10cd90adf48884b2d Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 2 Jun 2022 00:37:36 +0000 Subject: [PATCH] Use Image class from public API Signed-off-by: Christopher Ng --- apps/dav/lib/CardDAV/PhotoCache.php | 2 +- apps/settings/lib/UserMigration/AccountMigrator.php | 2 +- core/Controller/AvatarController.php | 6 +++--- lib/private/Avatar/Avatar.php | 5 ++--- lib/private/Avatar/UserAvatar.php | 5 ++--- lib/private/Preview/Bitmap.php | 2 +- lib/private/Preview/Bundled.php | 2 +- lib/private/Preview/Generator.php | 2 +- lib/private/Preview/HEIC.php | 2 +- lib/private/Preview/Image.php | 2 +- lib/private/Preview/MP3.php | 2 +- lib/private/Preview/MarkDown.php | 2 +- lib/private/Preview/Movie.php | 2 +- lib/private/Preview/Office.php | 2 +- lib/private/Preview/SVG.php | 2 +- lib/private/Preview/TXT.php | 2 +- 16 files changed, 20 insertions(+), 22 deletions(-) diff --git a/apps/dav/lib/CardDAV/PhotoCache.php b/apps/dav/lib/CardDAV/PhotoCache.php index 777a0b0e169..101111f9310 100644 --- a/apps/dav/lib/CardDAV/PhotoCache.php +++ b/apps/dav/lib/CardDAV/PhotoCache.php @@ -133,7 +133,7 @@ class PhotoCache { throw new NotFoundException; } - $photo = new \OC_Image(); + $photo = new \OCP\Image(); /** @var ISimpleFile $file */ $file = $folder->getFile('photo.' . $ext); $photo->loadFromData($file->getContent()); diff --git a/apps/settings/lib/UserMigration/AccountMigrator.php b/apps/settings/lib/UserMigration/AccountMigrator.php index bf1af10d464..4db28306eb1 100644 --- a/apps/settings/lib/UserMigration/AccountMigrator.php +++ b/apps/settings/lib/UserMigration/AccountMigrator.php @@ -153,7 +153,7 @@ class AccountMigrator implements IMigrator, ISizeEstimationMigrator { $output->writeln('Importing avatar from ' . $importPath . '…'); $stream = $importSource->getFileAsStream($importPath); - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromFileHandle($stream); try { diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index e75b3493185..2ef219af498 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -201,7 +201,7 @@ class AvatarController extends Controller { } try { - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData($content); $image->readExif($content); $image->fixOrientation(); @@ -260,7 +260,7 @@ class AvatarController extends Controller { Http::STATUS_NOT_FOUND); } - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData($tmpAvatar); $resp = new DataDisplayResponse( @@ -296,7 +296,7 @@ class AvatarController extends Controller { Http::STATUS_BAD_REQUEST); } - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData($tmpAvatar); $image->crop($crop['x'], $crop['y'], (int)round($crop['w']), (int)round($crop['h'])); try { diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php index 3bd58bb7681..f0e14ad8b2f 100644 --- a/lib/private/Avatar/Avatar.php +++ b/lib/private/Avatar/Avatar.php @@ -38,7 +38,6 @@ namespace OC\Avatar; use Imagick; use OC\Color; -use OC_Image; use OCP\Files\NotFoundException; use OCP\IAvatar; use Psr\Log\LoggerInterface; @@ -106,7 +105,7 @@ abstract class Avatar implements IAvatar { return false; } - $avatar = new OC_Image(); + $avatar = new \OCP\Image(); $avatar->loadFromData($file->getContent()); return $avatar; } @@ -148,7 +147,7 @@ abstract class Avatar implements IAvatar { $avatar->setFont($font); $avatar->readImageBlob($svg); $avatar->setImageFormat('png'); - $image = new OC_Image(); + $image = new \OCP\Image(); $image->loadFromData((string)$avatar); $data = $image->data(); return $data === null ? false : $data; diff --git a/lib/private/Avatar/UserAvatar.php b/lib/private/Avatar/UserAvatar.php index b46e4816fa2..6cca5a1c355 100644 --- a/lib/private/Avatar/UserAvatar.php +++ b/lib/private/Avatar/UserAvatar.php @@ -31,7 +31,6 @@ namespace OC\Avatar; use OC\NotSquareException; use OC\User\User; -use OC_Image; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFile; @@ -130,7 +129,7 @@ class UserAvatar extends Avatar { return $data; } - $img = new OC_Image(); + $img = new \OCP\Image(); if ( (is_resource($data) && get_resource_type($data) === 'gd') || (is_object($data) && get_class($data) === \GdImage::class) @@ -279,7 +278,7 @@ class UserAvatar extends Avatar { $data = $this->generateAvatar($this->getDisplayName(), $size); } } else { - $avatar = new OC_Image(); + $avatar = new \OCP\Image(); $file = $this->folder->getFile('avatar.' . $ext); $avatar->loadFromData($file->getContent()); $avatar->resize($size); diff --git a/lib/private/Preview/Bitmap.php b/lib/private/Preview/Bitmap.php index f7c8cf3543b..ffe5bc88856 100644 --- a/lib/private/Preview/Bitmap.php +++ b/lib/private/Preview/Bitmap.php @@ -68,7 +68,7 @@ abstract class Bitmap extends ProviderV2 { $this->cleanTmpFiles(); //new bitmap image object - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData((string) $bp); //check if image object is valid return $image->valid() ? $image : null; diff --git a/lib/private/Preview/Bundled.php b/lib/private/Preview/Bundled.php index 063c69ba5dd..df7f630dff7 100644 --- a/lib/private/Preview/Bundled.php +++ b/lib/private/Preview/Bundled.php @@ -43,7 +43,7 @@ abstract class Bundled extends ProviderV2 { $zip = new ZIP($sourceTmp); $zip->extractFile($path, $targetTmp); - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromFile($targetTmp); $image->fixOrientation(); diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index d52191544f3..ef44188da74 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -217,7 +217,7 @@ class Generator { // Free memory being used by the embedded image resource. Without this the image is kept in memory indefinitely. // Garbage Collection does NOT free this memory. We have to do it ourselves. - if ($maxPreviewImage instanceof \OC_Image) { + if ($maxPreviewImage instanceof \OCP\Image) { $maxPreviewImage->destroy(); } diff --git a/lib/private/Preview/HEIC.php b/lib/private/Preview/HEIC.php index 7ce6b93ba3b..ec200defce8 100644 --- a/lib/private/Preview/HEIC.php +++ b/lib/private/Preview/HEIC.php @@ -89,7 +89,7 @@ class HEIC extends ProviderV2 { $this->cleanTmpFiles(); //new bitmap image object - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData((string) $bp); //check if image object is valid return $image->valid() ? $image : null; diff --git a/lib/private/Preview/Image.php b/lib/private/Preview/Image.php index 4bf0cb7a3d4..55e1220b56a 100644 --- a/lib/private/Preview/Image.php +++ b/lib/private/Preview/Image.php @@ -45,7 +45,7 @@ abstract class Image extends ProviderV2 { return null; } - $image = new \OC_Image(); + $image = new \OCP\Image(); $fileName = $this->getLocalFile($file); diff --git a/lib/private/Preview/MP3.php b/lib/private/Preview/MP3.php index dec838b6e5a..47d752af477 100644 --- a/lib/private/Preview/MP3.php +++ b/lib/private/Preview/MP3.php @@ -56,7 +56,7 @@ class MP3 extends ProviderV2 { } if (!is_null($picture)) { - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData($picture); if ($image->valid()) { diff --git a/lib/private/Preview/MarkDown.php b/lib/private/Preview/MarkDown.php index 929f319f57d..d3806ce6c0e 100644 --- a/lib/private/Preview/MarkDown.php +++ b/lib/private/Preview/MarkDown.php @@ -137,7 +137,7 @@ class MarkDown extends TXT { } } - $imageObject = new \OC_Image(); + $imageObject = new \OCP\Image(); $imageObject->setResource($image); return $imageObject->valid() ? $imageObject : null; diff --git a/lib/private/Preview/Movie.php b/lib/private/Preview/Movie.php index 781cbad1954..5cb66a00881 100644 --- a/lib/private/Preview/Movie.php +++ b/lib/private/Preview/Movie.php @@ -145,7 +145,7 @@ class Movie extends ProviderV2 { exec($cmd, $output, $returnCode); if ($returnCode === 0) { - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromFile($tmpPath); if ($image->valid()) { unlink($tmpPath); diff --git a/lib/private/Preview/Office.php b/lib/private/Preview/Office.php index 570988aa684..6717584e887 100644 --- a/lib/private/Preview/Office.php +++ b/lib/private/Preview/Office.php @@ -83,7 +83,7 @@ abstract class Office extends ProviderV2 { return null; } - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData((string) $png); $this->cleanTmpFiles(); diff --git a/lib/private/Preview/SVG.php b/lib/private/Preview/SVG.php index a4ce4899c43..fd472083533 100644 --- a/lib/private/Preview/SVG.php +++ b/lib/private/Preview/SVG.php @@ -68,7 +68,7 @@ class SVG extends ProviderV2 { } //new image object - $image = new \OC_Image(); + $image = new \OCP\Image(); $image->loadFromData((string) $svg); //check if image object is valid if ($image->valid()) { diff --git a/lib/private/Preview/TXT.php b/lib/private/Preview/TXT.php index bb3af6b90de..f5a68f92be4 100644 --- a/lib/private/Preview/TXT.php +++ b/lib/private/Preview/TXT.php @@ -103,7 +103,7 @@ class TXT extends ProviderV2 { } } - $imageObject = new \OC_Image(); + $imageObject = new \OCP\Image(); $imageObject->setResource($image); return $imageObject->valid() ? $imageObject : null; -- 2.39.5