aboutsummaryrefslogtreecommitdiffstats
path: root/apps/testing/lib/Conversion/ConversionProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/testing/lib/Conversion/ConversionProvider.php')
-rw-r--r--apps/testing/lib/Conversion/ConversionProvider.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/testing/lib/Conversion/ConversionProvider.php b/apps/testing/lib/Conversion/ConversionProvider.php
index 15e468b0756..b8d93428694 100644
--- a/apps/testing/lib/Conversion/ConversionProvider.php
+++ b/apps/testing/lib/Conversion/ConversionProvider.php
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace OCA\Testing\Conversion;
-use OCP\Files\Conversion\ConversionMimeTuple;
+use OCP\Files\Conversion\ConversionMimeProvider;
use OCP\Files\Conversion\IConversionProvider;
use OCP\Files\File;
use OCP\IL10N;
@@ -22,19 +22,26 @@ class ConversionProvider implements IConversionProvider {
public function getSupportedMimeTypes(): array {
return [
- new ConversionMimeTuple('image/jpeg', [
- ['mime' => 'image/png', 'name' => $this->l10n->t('Image (.png)')],
- ])
+ new ConversionMimeProvider('image/jpeg', 'image/png', 'png', $this->l10n->t('Image (.png)')),
+ new ConversionMimeProvider('image/jpeg', 'image/gif', 'gif', $this->l10n->t('Image (.gif)')),
];
}
public function convertFile(File $file, string $targetMimeType): mixed {
$image = imagecreatefromstring($file->getContent());
-
imagepalettetotruecolor($image);
+ // Start output buffering
ob_start();
- imagepng($image);
+
+ // Convert the image to the target format
+ if ($targetMimeType === 'image/gif') {
+ imagegif($image);
+ } else {
+ imagepng($image);
+ }
+
+ // End and return the output buffer
return ob_get_clean();
}
}