From 02682eb20bb5aa3e5bf7b6e91d88252ec93025cc Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Wed, 3 May 2023 18:45:51 +0200 Subject: [PATCH] Ensuring jpeg is never used. --- lib/BurguillosInfo/Posts.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/BurguillosInfo/Posts.pm b/lib/BurguillosInfo/Posts.pm index 3de5b3c..ad368ae 100644 --- a/lib/BurguillosInfo/Posts.pm +++ b/lib/BurguillosInfo/Posts.pm @@ -259,6 +259,7 @@ sub _AttachImageSVG { system qw/file --mime-type/, $image; }; my ($format) = $output =~ /(\S+)$/; + say $format; $svg->image( x => $x, y => $y, @@ -274,6 +275,14 @@ sub _GenerateSVGPostPreview { my $title = shift; my $content = 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 $svg = SVG->new( width => $SVG_WIDTH, height => $SVG_HEIGHT ); $svg->rect(