Trying bigger cards in this trying times.

This commit is contained in:
Sergiotarxz 2024-05-23 16:12:59 +02:00
parent 30ed9e61df
commit 201a220cba
1 changed files with 9 additions and 7 deletions

View File

@ -91,7 +91,9 @@ sub _generate_pdf ( $self, $cards, $images ) {
$page->size('A4');
my @rectangle = $page->size;
my $width_paper = $rectangle[2];
my $n_pixels_per_cm = $width_paper / 21.0;
my $height_paper = $rectangle[3];
my $n_pixels_per_cm_width = $width_paper / 21.0;
my $n_pixels_per_cm_height = $height_paper / 29.7;
for my $card (@$cards) {
my $images_card = $images->{ $card->{scryfallId} };
for my $image_kind ( keys %$images_card ) {
@ -103,26 +105,26 @@ sub _generate_pdf ( $self, $cards, $images ) {
}
my $margin_bottom = 25;
my $mtg_card_width = 6.35;
my $mtg_card_height = 8.89;
my $mtg_card_height = 9.15;
my $small_line_to_cut_better_size = 0.5;
open my $fh, '<', \$images_card->{$image_kind};
my $image = $pdf->image( $fh, format => 'jpeg' );
my $margin_left =
( $width_paper -
( $n_pixels_per_cm * $mtg_card_width * 3 ) -
( $n_pixels_per_cm_width * $mtg_card_width * 3 ) -
( $small_line_to_cut_better_size * 2 ) ) / 2;
my $page_position_x = $number_image % 3;
my $page_position_y = abs( int( $number_image / 3 ) - 2 );
$page->object(
$image,
$margin_left +
$page_position_x * $mtg_card_width * $n_pixels_per_cm +
$page_position_x * $mtg_card_width * $n_pixels_per_cm_width +
$small_line_to_cut_better_size * $page_position_x,
$margin_bottom +
$page_position_y * $mtg_card_height * $n_pixels_per_cm +
$page_position_y * $mtg_card_height * $n_pixels_per_cm_height +
$small_line_to_cut_better_size * $page_position_y,
$n_pixels_per_cm * $mtg_card_width,
$n_pixels_per_cm * $mtg_card_height,
$n_pixels_per_cm_width * $mtg_card_width,
$n_pixels_per_cm_height * $mtg_card_height,
);
$number_image++;
}