-
Notifications
You must be signed in to change notification settings - Fork 1
/
flip.pl
36 lines (33 loc) · 1.08 KB
/
flip.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl
# Adapted from http://www.ex-parrot.com/~pete/upside-down-ternet.html
$directory = "/var/tmp/upsidedownternet";
umask 0022;
mkdir($directory, 0775) unless(-d $directory);
$|=1;
$count = 0;
$pid = $$;
while (<>) {
chomp $_;
if ($_ =~ /(.*\.jpg)/i) {
$url = $1;
system("/usr/bin/wget", "-q", "-O", "/var/tmp/upsidedownternet/$pid-$count.jpg", "$url");
system("/usr/bin/mogrify", "-flip", "/var/tmp/upsidedownternet/$pid-$count.jpg");
print "http://127.0.0.1/images/$pid-$count.jpg\n";
}
elsif ($_ =~ /(.*\.gif)/i) {
$url = $1;
system("/usr/bin/wget", "-q", "-O", "/var/tmp/upsidedownternet/$pid-$count.gif", "$url");
system("/usr/bin/mogrify", "-flip", "/var/tmp/upsidedownternet/$pid-$count.gif");
print "http://127.0.0.1/images/$pid-$count.gif\n";
}
elsif ($_ =~ /(.*\.png)/i) {
$url = $1;
system("/usr/bin/wget", "-q", "-O", "/var/tmp/upsidedownternet/$pid-$count.png", "$url");
system("/usr/bin/mogrify", "-flip", "/var/tmp/upsidedownternet/$pid-$count.png");
print "http://127.0.0.1/images/$pid-$count.png\n";
}
else {
print "$_\n";
}
$count++;
}