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(); // 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(); } }