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
|
#!/usr/bin/env php
<?php
// Recreate local thumbnails
require_once('include/cli_startup.php');
require_once('include/photo/photo_driver.php');
cli_startup();
$x = q("SELECT resource_id, content, width, height, mimetype FROM photo WHERE photo_usage = 0 AND os_storage = 1 AND imgscale = 0");
if($x) {
foreach($x as $xx) {
$im = photo_factory(@file_get_contents(dbunescbin($xx['content'])), $xx['mimetype']);
$width = $xx['width'];
$height = $xx['height'];
$n = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale > 0",
dbesc($xx['resource_id'])
);
foreach($n as $nn) {
echo $nn['imgscale'];
$nn['os_path'] = $xx['os_path'];
switch ($nn['imgscale']) {
case 1:
if($width > 1024 || $height > 1024)
$im->scaleImage(1024);
$im->storeThumbnail($nn, PHOTO_RES_1024);
break;
case 2:
if($width > 640 || $height > 640)
$im->scaleImage(640);
$im->storeThumbnail($nn, PHOTO_RES_640);
break;
case 3:
if($width > 320 || $height > 320)
$im->scaleImage(320);
$im->storeThumbnail($nn, PHOTO_RES_320);
break;
case 4:
$im->storeThumbnail($nn, PHOTO_RES_PROFILE_300);
break;
case 5:
$im->scaleImage(80);
$im->storeThumbnail($nn, PHOTO_RES_PROFILE_80);
break;
case 6:
$im->scaleImage(48);
$im->storeThumbnail($nn, PHOTO_RES_PROFILE_48);
break;
case 7:
$im->storeThumbnail($nn, PHOTO_RES_COVER_1200);
break;
case 8:
$im->doScaleImage(850,310);
$im->storeThumbnail($nn, PHOTO_RES_COVER_850);
break;
case 9:
$im->doScaleImage(425,160);
$im->storeThumbnail($nn, PHOTO_RES_COVER_425);
break;
}
}
}
}
|