0

Is there a possibility to use the image manipulation tool of TYPO3 to crop images in the TYPO3 backend in order to use cropVariants in the frontend also for PDF files?

The image manipulation tool only shows the message:

No image dimensions could be determined.
Unable to provide image manipulation, because original dimensions of the image are unknown.

Maybe I need another server side module? But I wasn't able to find any information on this topic.

Peter Kraume
  • 2,610
  • 2
  • 14
  • 28
  • Now I have a similar problem: I want a preview Image for Download. As it works for JPG it fails for PNG (the original file is referenced which can't be viewed as image), additional the `width` and `height` is `0` (using the same PDF in a Text with Image CE shows a nice preview image of the PDF) – Bernd Wilke πφ Feb 10 '20 at 14:13
  • =:-O Whitespaces in filenames, which are not handled correctly everywhere. :-( – Bernd Wilke πφ Feb 10 '20 at 14:46

2 Answers2

2

Most probably everything within TYPO3 works. Just for security reasons, your Unix Distribution disabled handling of GhostScript files (PDF, AI, etc.) through ImageMagick for security concerns.

Depending on your Distribution, there is a file /etc/ImageMagick-6/policy.xml. This file defines which files are allowed to be processed. If you are "save" or don't care, comment out that PDF is not allowed.

I've the following section in my local setup:

  <!-- disable ghostscript format types -->
  <policy domain="coder" rights="none" pattern="PS" />
  <policy domain="coder" rights="none" pattern="PS2" />
  <policy domain="coder" rights="none" pattern="PS3" />
  <policy domain="coder" rights="none" pattern="EPS" />
  <policy domain="coder" rights="none" pattern="PDF" />
  <policy domain="coder" rights="none" pattern="XPS" />

These files are not allowed to be processed. All can contain GhostScript. Also see:

I'm not an security expert, but would expect that you open an security issue by enabling processing of those files. So maybe make sure who is allowed to upload files containing GhostScript instructions. E.g. limit to trusted backend users.

Daniel
  • 782
  • 4
  • 10
1

There is/was a security problem with ghostscript, which is used by ImageMagick/GraphicsMagick to work with PDFs and EPS.
That's the reason you will find those filetypes disabled in some distributionsin the configuration of IM/GM.

Look in the imagetests: can PDFs be read? probably you will find an error like:

Read pdf
Image generation failed
ImageMagick / GraphicsMagick handling is enabled, but the execute command returned an error. Please check your settings, especially ['GFX']['processor_path'] and ['GFX']['processor_path_lzw'] and ensure Ghostscript is installed on your server.

In this article you can get more information.

example from an Ubuntu distribution:
in /etc/ImageMagick-6/policy.xml you find

<!-- disable ghostscript format types -->
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />

Another workaround for Suse can be found in this TYPO3 ticket (although it is no bug of TYPO3)

Bernd Wilke πφ
  • 8,555
  • 1
  • 13
  • 32
  • "Read pdf" Test in the TYPO3 install tool works fine and also using PDF files as image in the frontend works. It's just the image manipulation which is failing. But I assume that the server provider disabled ghostscript as you mentioned. I'll check with the support. – Peter Kraume Feb 10 '20 at 08:45
  • If `ghostscript` is disabled you can't use PDFs as images at all and you also get no preview images in the BE. – Bernd Wilke πφ Feb 10 '20 at 10:22
  • Regarding your image processing of PDFs is working in general it might be a problem of size determination of PDFs. As they are handled as vector images they can't have a clear size. In this way the cropping can't work as it needs size and offset in pixels. Maybe a feature request could bring a fix. – Bernd Wilke πφ Feb 10 '20 at 10:28