From 2b924fac4b306f6ca60efa5503c6cac8df2dd2e8 Mon Sep 17 00:00:00 2001 From: James Collins Date: Wed, 24 Apr 2024 18:06:38 +1000 Subject: [PATCH] removed from project --- app/MediaServices/Converters/HEICToJPEG.php | 97 ------------------- app/MediaServices/MediaService.php | 37 ------- app/MediaServices/MediaServiceData.php | 53 ---------- .../Transformers/ImageRotate.php | 76 --------------- 4 files changed, 263 deletions(-) delete mode 100644 app/MediaServices/Converters/HEICToJPEG.php delete mode 100644 app/MediaServices/MediaService.php delete mode 100644 app/MediaServices/MediaServiceData.php delete mode 100644 app/MediaServices/Transformers/ImageRotate.php diff --git a/app/MediaServices/Converters/HEICToJPEG.php b/app/MediaServices/Converters/HEICToJPEG.php deleted file mode 100644 index 3543126..0000000 --- a/app/MediaServices/Converters/HEICToJPEG.php +++ /dev/null @@ -1,97 +0,0 @@ -getData(ImageInterface::class, function() use ($data) { - $manager = new ImageManager(new Driver()); - $image = $manager->read($data->file()); - if($image === null) { - throw new MediaServiceException('Could not read file.'); - } - - return $image; - }); - - $quality = $data->option('heictojpeg', 'quality', 90); - $encoded = $image->toJpeg($quality); - $encoded->save($data->file()); // this needs to be renamed with the new extension - - if(!$data->nextSupports(ImageInterface::class)) { - $image->save(); - $data->removeData(ImageInterface::class); - } - - Image::make($tempFile) - ->save($tempJpgFile); - - $media->set - $media->mime_type = 'image/jpeg'; - - - - /*****/ - - - $filePath = $file['dirname'] . '/' . $file['name'] . '.' . $file['extension']; - $jpgFileName = MediaController::makeNewFilename($file['name'], 'jpg'); - - Image::make($filePath) - ->save($file['dirname'] . '/' . $jpgFileName); - - $file['name'] = pathinfo($jpgFileName, PATHINFO_FILENAME); - $file['extension'] = 'jpg'; - $file['mime_type'] = 'image/jpeg'; - $file['size'] = filesize($file['dirname'] . '/' . $jpgFileName); - - unlink($filePath); - - return true; - } -} diff --git a/app/MediaServices/MediaService.php b/app/MediaServices/MediaService.php deleted file mode 100644 index d1014c2..0000000 --- a/app/MediaServices/MediaService.php +++ /dev/null @@ -1,37 +0,0 @@ -data[$key] ?? $default; - } - - /** - * Set the data in the data array. - * - * @param string $key The key to set. - * @param mixed $value The value to set. - * @return void - */ - public function set(string $key, $value): void - { - $this->data[$key] = $value; - } - - /** - * Get the data from the data array or create it if it does not exist. - * - * @param string $key The key to get. - * @param callable $default The default value to return if the key does not exist. - * @return mixed The value of the key. - */ - public function getChainData(string $key, callable $default) - { - if (!isset($this->data[$key])) { - $this->data[$key] = $default(); - } - - return $this->data[$key]; - } -} diff --git a/app/MediaServices/Transformers/ImageRotate.php b/app/MediaServices/Transformers/ImageRotate.php deleted file mode 100644 index cd94214..0000000 --- a/app/MediaServices/Transformers/ImageRotate.php +++ /dev/null @@ -1,76 +0,0 @@ -getData(ImageInterface::class, function() use ($data) { - $manager = new ImageManager(new Driver()); - $image = $manager->read($data->file()); - if($image === null) { - throw new MediaServiceException('Could not read file.'); - } - - return $image; - }); - - $degrees = $data->option('rotate', 'degrees', 90); - $image->rotate($degrees); - - if(!$data->nextSupports(ImageInterface::class)) { - $image->save(); - $data->removeData(ImageInterface::class); - } - } -}