Resize jpg quality irssi perl

Closed Posted 5 years ago Paid on delivery
Closed Paid on delivery

I have an irssi bot that saves me the images in mysql database but before saving them I would like to make a resize maintaining the quality, the images have all different resolutions.

the code to which I must add the resize is this

sub saveJpg {

my ($text, $server, $channel, $nick) = @_;

my $time = time();

my ($pre, $url, $jpgname, $checksum) = split(" ", $text);

$pre = trim($pre);

$url = trim($url);

$jpgname = trim($jpgname);

if (length($jpgname) > $limits{'jpgnameLength'}) {

my $message = "[".$red."ERROR".$reset."] ".$darkgrey."savejpg()--[jpg file name too long]--[!addjpg $pre $url $jpgname ]--[$nick]--[$channel]";

announceError($server, $message);

printDebug("savejpg()--[Filename too long]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]");

return 0;

}

my $jpg2 = stripBadCharsFile($jpgname);

my $url2 = stripBadCharsUrl($url);

# escape ( and ) chars

$jpg2 =~ s/\(/\\\(/g;

$jpg2 =~ s/\)/\\\)/g;

$url2 =~ s/\(/\\\(/g;

$url2 =~ s/\)/\\\)/g;

my $hash = md5_hex($pre);

my $botId = checkBot($nick, "jpg");

if (!$botId) {

printDebug("savejpg()--[Bot $nick does not have jpg saving rights]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]");

return 0;

}

if (checkIfPreExists($pre) != 1) {

my $message = "[".$red."ERROR".$reset."] ".$darkgrey."savejpg()--[No such pre in db]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]";

announceError($server, $message);

printDebug("savejpg()--[No such pre in db]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]");

return 0;

}

if ($pre) {

my $sql = "SELECT [login to view URL], [login to view URL], [login to view URL] FROM jpgs j LEFT JOIN releases AS r ON [login to view URL] = [login to view URL] WHERE [login to view URL] = ? and [login to view URL] = ? LIMIT 1";

my @params = ($pre, $jpgname);

if (runSqlSingle($sql, @params)) {

printDebug("saveJpg()--[Jpgs already exists]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]");

return 0;

}

}

printDebug("savejpg()--[!addjpg $pre $url $jpgname]--[$nick]--[$channel]--START--");

my $releaseId = getReleaseId($pre);

my $channelId = getChannelId($channel);

my $command = "wget -q -T 1 -t 1 --no-check-certificate --content-disposition -O $jpg2 $url2";

system($command);

rename("$jpgname", "$hash");

my $filesize = -s "$hash";

if ($filesize < 10000 || $filesize > 4240000 ) {

unlink("$hash");

printDebug("savejpg()--[Invalid filesize]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]");

return 0;

}

open(FILE, "$hash") or die $!;

my @data = <FILE>;

close FILE;

my $jpgdata = join('',@data);

$jpgdata = encode_base64($jpgdata);

my $sql = "INSERT INTO jpgs(releaseid, hash, jpg, jpgname, time, \

channelid, botid) VALUES (?, ?, ?, ?, ?, ?, ?)";

my @params = ($releaseId, $hash, $jpgdata, $jpgname, $time, $channelId, $botId);

if (!runSqlSave($sql, @params)) {

my $message = "[".$red."ERROR".$reset."] ".$darkgrey."savejpg()--[Unable to save jpg into db]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]";

announceError($server, $message);

printDebug("savejpg()--[Unable to save jpg into db]--[!addjpg $pre $url $jpgname $checksum]--[$nick]--[$channel]");

unlink("$hash");

return 0;

}

Linux MySQL Perl PHP Shell Script

Project ID: #16953034

About the project

4 proposals Remote project Active 5 years ago

4 freelancers are bidding on average €22 for this job

zkutch

Hello More 20 years programming experience. I need more details to set real price and time. Regards. ----------------------------------------------------------------------------------------------------------------- More

€34 EUR in 3 days
(39 Reviews)
5.4
aniketgadhia

A proposal has not yet been provided

€14 EUR in 2 days
(0 Reviews)
0.0