NAME
App::pdfresize - Resize each page of PDF file to a new dimension
VERSION
This document describes version 0.001 of App::pdfresize (from Perl
distribution App-pdfresize), released on 2024-08-20.
SYNOPSIS
# Use via pdfsize CLI script
FUNCTIONS
pdfresize
Usage:
pdfresize(%args) -> [$status_code, $reason, $payload, \%result_meta]
Resize each page of PDF file to a new dimension.
Examples:
* Shrink PDF dimension to 25% original size (half the width, half the
height):
pdfresize(filename => "foo.pdf", resize => "50%x50%");
Result:
[
500,
"Function died: system(pdftk /home/u1/repos/perl-App-pdfresize/foo.pdf burst) failed: 256 (exited with code 1) at /home/u1/perl5/perlbrew/perls/perl-5.38.2/lib/site_perl/5.38.2/IPC/System/Options.pm line 440.\n",
undef,
{
logs => [
{
file => "/home/u1/perl5/perlbrew/perls/perl-5.38.2/lib/site_perl/5.38.2/Perinci/Access/Schemeless.pm",
func => "Perinci::Access::Schemeless::action_call",
line => 499,
package => "Perinci::Access::Schemeless",
time => 1724149492,
type => "create",
},
],
},
]
* Shrink PDF page height to 720p, and use quality 40, name an output:
pdfresize(
filename => "foo.pdf",
resize => "x720>",
output_filename => "foo-resized.pdf",
quality => 40
);
Result:
[
500,
"Function died: system(pdftk /home/u1/repos/perl-App-pdfresize/foo.pdf burst) failed: 256 (exited with code 1) at /home/u1/perl5/perlbrew/perls/perl-5.38.2/lib/site_perl/5.38.2/IPC/System/Options.pm line 440.\n",
undef,
{
logs => [
{
file => "/home/u1/perl5/perlbrew/perls/perl-5.38.2/lib/site_perl/5.38.2/Perinci/Access/Schemeless.pm",
func => "Perinci::Access::Schemeless::action_call",
line => 499,
package => "Perinci::Access::Schemeless",
time => 1724149492,
type => "create",
},
],
},
]
This utility first splits a PDF to individual pages (using pdftk), then
converts each page to JPEG and resizes it (using ImageMagick's convert),
then converts back each page to PDF and reassembles the resized pages to
a new PDF.
This function is not exported.
Arguments ('*' denotes required arguments):
* filename* => *filename*
(No description)
* output_filename => *filename*
(No description)
* quality => *int*
(No description)
* resize* => *filename*
ImagaMagick resize notation, e.g. "50%x50%", "x720>".
See ImageMagick documentation (e.g. convert) for more details, or
the documentation of calc-image-resized-size,
image-resize-notation-to-human for lots of examples.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
HOMEPAGE
Please visit the project's homepage at
SOURCE
Source repository is at
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull
requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You
can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally
on your system), you can install Dist::Zilla,
Dist::Zilla::PluginBundle::Author::PERLANCAR,
Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
BUGS
Please report any bugs or feature requests on the bugtracker website
When submitting a bug or request, please include a test-file or a patch
to an existing test-file that illustrates the bug or desired feature.