+ /**
+ * Get the content of an image based64 encoded.
+ */
+ public function getAsBase64($id)
+ {
+ $image = $this->imageRepo->getById($id);
+ if (is_null($image) || $image->type !== 'drawio' || !userCan('page-view', $image->getPage())) {
+ return $this->jsonError('Image data could not be found');
+ }
+
+ $imageData = $this->imageRepo->getImageData($image);
+ if (is_null($imageData)) {
+ return $this->jsonError('Image data could not be found');
+ }
+
+ return response()->json([
+ 'content' => base64_encode($imageData),
+ ]);
+ }