aboutsummaryrefslogtreecommitdiffstats
path: root/util/thumbrepair
diff options
context:
space:
mode:
authorManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-08-11 10:39:03 +0200
committerManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-08-11 10:39:03 +0200
commitb89d2d7580e40cd417defaffd2514b5eed38577d (patch)
tree78ba9004d87b994dd9a531b475fd51b940bf3dd8 /util/thumbrepair
parent350e636e3d0a44323c69185555e89cc01a213aa2 (diff)
parent047dd31724f8da12c153b4a6f27dc5462f7b97e5 (diff)
downloadvolse-hubzilla-b89d2d7580e40cd417defaffd2514b5eed38577d.tar.gz
volse-hubzilla-b89d2d7580e40cd417defaffd2514b5eed38577d.tar.bz2
volse-hubzilla-b89d2d7580e40cd417defaffd2514b5eed38577d.zip
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat (limited to 'util/thumbrepair')
-rwxr-xr-xutil/thumbrepair74
1 files changed, 74 insertions, 0 deletions
diff --git a/util/thumbrepair b/util/thumbrepair
new file mode 100755
index 000000000..acd453719
--- /dev/null
+++ b/util/thumbrepair
@@ -0,0 +1,74 @@
+#!/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, os_path 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->scaleImage(300);
+ $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->doScaleImage(1200,435);
+ $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;
+ }
+ }
+ }
+}
+