Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PDF TrimBox when generating previews #6276

Merged
merged 3 commits into from Aug 15, 2023

Conversation

ausi
Copy link
Member

@ausi ausi commented Aug 10, 2023

AFAIK the TrimBox is the bounding box that most programs use for PDF previews.

See https://community.contao.org/de/showthread.php?85566

@ausi ausi added the bug label Aug 10, 2023
@ausi ausi added this to the 4.13 milestone Aug 10, 2023
@ausi ausi requested a review from fritzmg August 10, 2023 13:28
@ausi ausi self-assigned this Aug 10, 2023
fritzmg
fritzmg previously approved these changes Aug 10, 2023
@fritzmg
Copy link
Contributor

fritzmg commented Aug 10, 2023

Looks correct to me (but I am unable to verify at the moment).

@ausi
Copy link
Member Author

ausi commented Aug 10, 2023

AFAIK the TrimBox is the bounding box that most programs use for PDF previews.

Looks like this info was not accurate, Apple Preview uses the CropBox for example.

But I still think for our preview, the trimbox usually makes more sense, as we probably do not want to show crop marks and bleed.

Toflar
Toflar previously approved these changes Aug 10, 2023
@kroerig
Copy link

kroerig commented Aug 10, 2023

I adopted the changes to my demo installation, but it does not work. No preview is created anymore with the changes.

@ausi
Copy link
Member Author

ausi commented Aug 10, 2023

@kroerig can you please post a screeshot of your changed source code?

Are you using ImageMagick or GraphicsMagick?
Did you clear the preview cache after your changes?

@kroerig
Copy link

kroerig commented Aug 10, 2023

grafik

Yes, i cleared all caches.

GraphicsMagick 6.9.10.23

@kroerig
Copy link

kroerig commented Aug 10, 2023

Yeah, got it working. Had to switch to ImageMagick and now I get nice previews. Thx a lot.

@ausi ausi dismissed stale reviews from Toflar and fritzmg via c0fc445 August 10, 2023 20:05
@ausi
Copy link
Member Author

ausi commented Aug 10, 2023

Does anyone know how to set pdf:use-trimbox=true in GraphicsMagick, or if this is even supported at all?

A similar option should be available according to http://www.graphicsmagick.org/NEWS.html#december-24-2011:

Support application of the PDF crop box via '-define pdf:use-cropbox=true'.

But I don’t know how to do a -define via GMagick in PHP.

@ausi
Copy link
Member Author

ausi commented Aug 10, 2023

@kroerig can you please check if the latest version of this pull request works for GraphicsMagick too?

@kroerig
Copy link

kroerig commented Aug 10, 2023

Unfortunately, I don't have Gmagick in PHP. That's why I had to switch to ImageMagick to make it work.

@fritzmg
Copy link
Contributor

fritzmg commented Aug 11, 2023

I tested the changes of this PR with the PDF from https://community.contao.org/de/showthread.php?85566 on a shared hosting from Hostingwerk, which uses Gmagick. However, it does not appear to work. The preview image stays the same.

@fritzmg
Copy link
Contributor

fritzmg commented Aug 11, 2023

Never mind, the changes work - I always only cleared the image cache instead of the preview cache 🙈

@leofeyer leofeyer merged commit 6b0dba8 into contao:4.13 Aug 15, 2023
17 checks passed
@leofeyer
Copy link
Member

Thank you @ausi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants