-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfreemind_map_from_images.php
executable file
·73 lines (60 loc) · 1.87 KB
/
freemind_map_from_images.php
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/php
<?php
$tsize = 100; //thumbnail size
function noresize($name)
{
global $argv;
$fullpath = $name; #$argv[1] . "/$name";
echo "<node TEXT=\"<html><img src="http://ktz.darktech.org/images/mindmaps/$fullpath"/> \" FOLDED=\"true\">\n</node>\n";
return;
}
function thumbit($name, $w, $h)
{
global $argv;
$fullpath = $name; #$argv[1] . "/$name";
echo "<node TEXT=\"<html><img src="http://ktz.darktech.org/images/mindmaps/$fullpath" width="$w" height="$h"\" FOLDED=\"true\">\n";
echo "<node TEXT=\"<html><img src="http://ktz.darktech.org/images/mindmaps/$fullpath"\" FOLDED=\"true\">\n</node>\n";
echo "<node LINK=\"http://ktz.darktech.org/images/mindmaps/$fullpath\" TEXT=\"$name\">\n</node>\n";
echo "</node>\n";
return;
}
if ($argc < 2)
{
#die("usage: " . $argv[0] . " IMAGEPATH IMAGE1 [[IMAGE2] ... ]\n");
die("usage: " . $argv[0] . " IMAGE1 [[IMAGE2] ... ]\n");
}
echo "<map version=\"0.7.1\">\n<node TEXT=\"Ian's image generator\" FOLDED=\"false\">\n<node TEXT=\"New Images\" FOLDED=\"true\">\n";
for ($i=1; $i<$argc; $i++)
{
$myimg = $argv[$i];
$props = getimagesize($myimg);
$w = $props[0];
$h = $props[1];
//make groups of 5 if there are more than 5 images
if ($argc > 6 && (($i-1) % 5 == 0))
echo "<node TEXT=\"Group " . (intval($i/5) + 1) . "\" FOLDED=\"true\">\n";
if ($w <= $tsize && $h <= $tsize)
{
noresize($myimg);
}
else if ($w < $h)
{
$w = intval(($tsize * $w) / $h);
$h = $tsize;
thumbit($myimg, $w, $h);
}
else
{
$h = intval(($tsize * $h) / $w);
$w = $tsize;
thumbit($myimg, $w, $h);
}
//close group of 5
if ($argc > 5 && (($i-1) % 5 == 4))
echo "</node>\n";
}
//close unfinisheed gorup of 5
if ($argc > 5 && (($i-2) % 5 != 4))
echo "</node>\n";
echo "</node>\n</node>\n</map>\n";
?>