Fixing previews again.
This commit is contained in:
parent
136f23d3be
commit
83e7b37b1e
@ -233,6 +233,7 @@ sub _AttachImageSVG {
|
|||||||
my $svg = shift;
|
my $svg = shift;
|
||||||
my $image = shift;
|
my $image = shift;
|
||||||
$image = $PUBLIC_DIR->child( './' . $image );
|
$image = $PUBLIC_DIR->child( './' . $image );
|
||||||
|
path($image = $self->_toPng($image));
|
||||||
my ( $stdout, $stderr, $error ) = capture {
|
my ( $stdout, $stderr, $error ) = capture {
|
||||||
system qw/identify -format "%wx%h"/, $image;
|
system qw/identify -format "%wx%h"/, $image;
|
||||||
};
|
};
|
||||||
@ -259,7 +260,6 @@ sub _AttachImageSVG {
|
|||||||
system qw/file --mime-type/, $image;
|
system qw/file --mime-type/, $image;
|
||||||
};
|
};
|
||||||
my ($format) = $output =~ /(\S+)$/;
|
my ($format) = $output =~ /(\S+)$/;
|
||||||
say $format;
|
|
||||||
$svg->image(
|
$svg->image(
|
||||||
x => $x,
|
x => $x,
|
||||||
y => $y,
|
y => $y,
|
||||||
@ -270,19 +270,23 @@ sub _AttachImageSVG {
|
|||||||
return $y + $height + 50;
|
return $y + $height + 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub _toPng($self, $image) {
|
||||||
|
if ($image =~ /\.\w+$/) {
|
||||||
|
my $new_image = $image =~ s/\.\w+$/.generated.png/r;
|
||||||
|
say $new_image;
|
||||||
|
if (!-e $new_image) {
|
||||||
|
system 'convert', "$image", "$new_image";
|
||||||
|
}
|
||||||
|
$image = $new_image;
|
||||||
|
}
|
||||||
|
return path($image);
|
||||||
|
}
|
||||||
|
|
||||||
sub _GenerateSVGPostPreview {
|
sub _GenerateSVGPostPreview {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $title = shift;
|
my $title = shift;
|
||||||
my $content = shift;
|
my $content = shift;
|
||||||
my $image = shift;
|
my $image = shift;
|
||||||
if ($image =~ /\.jpe?g$/) {
|
|
||||||
my $new_image = $image =~ s/\.jpe?g$/.generated.png/r;
|
|
||||||
my $dir = 'public';
|
|
||||||
if (!-e $new_image) {
|
|
||||||
system 'convert', "$dir/$image", "$dir/$new_image";
|
|
||||||
}
|
|
||||||
$image = $new_image;
|
|
||||||
}
|
|
||||||
my @content = @$content;
|
my @content = @$content;
|
||||||
my $svg = SVG->new( width => $SVG_WIDTH, height => $SVG_HEIGHT );
|
my $svg = SVG->new( width => $SVG_WIDTH, height => $SVG_HEIGHT );
|
||||||
$svg->rect(
|
$svg->rect(
|
||||||
@ -308,13 +312,15 @@ sub _GenerateSVGPostPreview {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $burguillos_logo_png = path($self->_toPng($BURGUILLOS_LOGO));
|
||||||
|
say ''.$burguillos_logo_png;
|
||||||
$group->image(
|
$group->image(
|
||||||
x => 10,
|
x => 10,
|
||||||
y => 5,
|
y => 5,
|
||||||
width => 40,
|
width => 40,
|
||||||
height => 40,
|
height => 40,
|
||||||
-href => 'data:image/webp;base64,'
|
-href => 'data:image/png;base64,'
|
||||||
. encode_base64( $BURGUILLOS_LOGO->slurp )
|
. encode_base64( $burguillos_logo_png->slurp )
|
||||||
);
|
);
|
||||||
$group->text(
|
$group->text(
|
||||||
x => 60,
|
x => 60,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user