b95a046b579d44d8d079af99757189d5ee282988
4 require_once 'connect.db.inc.php';
6 $globals->debug
= 0; // Do not store backtraces.
10 $it = XDB
::rawIterator('SELECT id, diminutif, logo, logo_mime
12 WHERE logo IS NOT NULL AND logo != ""');
14 while ($row = $it->next()) {
15 $group_id = $row['id'];
16 $group_name = $row['diminutif'];
19 $img = imagecreatefromstring($logo);
21 print "\n\nError reading image for:\n $group_name\n\n";
28 if ($x > $MAX_X ||
$y > $MAX_Y) {
30 $ny = intval($y * $MAX_X / $x);
34 $nx = intval($x*$MAX_Y/$y);
37 $img2 = imagecreatetruecolor($nx, $ny);
38 imagealphablending($img2, false
);
39 imagesavealpha($img2,true
);
40 $transparent = imagecolorallocatealpha($img2, 255, 255, 255, 127);
41 imagefilledrectangle($img2, 0, 0, $nx, $ny, $transparent);
42 imagecopyresampled($img2, $img, 0, 0, 0, 0, $nx, $ny, $x, $y);
43 $tmpf = tempnam('/tmp', 'upgrade_111_group_logos');
44 imagepng($img2, $tmpf);
45 $f = fopen($tmpf, 'r');
46 $logo2 = fread($f, filesize($tmpf));
49 XDB
::execute("UPDATE groups
50 SET logo = {?}, logo_mime = 'image/png'
51 WHERE id = {?}", $logo2, $group_id);