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

Convert big PDF documents is slow #7263

Merged
merged 3 commits into from Apr 20, 2024
Merged

Conversation

scresto09
Copy link
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practices as demonstrated in the repository.

Description

I noticed that saving large PDF files with ImageMagick was very slow, and it was generating the PDF ID entry which took a long time.
According to the PDF specification, this ID field is not required (page 47 of Document Management — Portable Document Format — Part 1: PDF 1.7).
So I added the "pdf:noID" option to the PDF encoders which allows this ID field not to be generated.

With a 3 MB JPG file, this goes from 1.12 s to 0.28 s.

Fixes #7262

…tion of PDF files

When this flag is set the optional ID tag is not generated into PDF
coders/pdf.c Outdated
GetImageProperty(image,"signature",exception),
GetImageProperty(image,"signature",exception));
(void) WriteBlobString(image,buffer);
option=GetImageOption(image_info,"pdf:noID");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pdf:no-identifier would probably be a better name and more consistent with the rest of the names we use.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I renamed to pdf:no-identifier

coders/pdf.c Outdated
(void) WriteBlobString(image,buffer);
option=GetImageOption(image_info,"pdf:noID");
if (IsStringTrue(option) != MagickFalse) {
(void) DeleteImageProperty(image,"signature");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to do this call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I removed this part.

@urban-warrior urban-warrior merged commit cf275e5 into ImageMagick:main Apr 20, 2024
8 checks passed
@scresto09
Copy link
Contributor Author

Thanks for merge

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

Successfully merging this pull request may close these issues.

Convert big PDF documents is slow
3 participants