aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2017-11-20 14:27:20 +0100
committerMario Vavti <mario@mariovavti.com>2017-11-20 14:27:20 +0100
commit0325efeb350f575f70f18e9f199ad273e5ba1d15 (patch)
tree742ffbc2b46a31547f114124546353d3b1102157 /include
parent9ab33f1e134e6e7694a42b92fc9d73c2e6dcffd1 (diff)
parent250d947667b1500633d80b043ac3760be21446fc (diff)
downloadvolse-hubzilla-0325efeb350f575f70f18e9f199ad273e5ba1d15.tar.gz
volse-hubzilla-0325efeb350f575f70f18e9f199ad273e5ba1d15.tar.bz2
volse-hubzilla-0325efeb350f575f70f18e9f199ad273e5ba1d15.zip
Merge remote-tracking branch 'mike/master' into dev
Diffstat (limited to 'include')
-rw-r--r--include/attach.php3
-rw-r--r--include/photo/photo_driver.php109
-rw-r--r--include/photos.php8
-rw-r--r--include/text.php4
4 files changed, 74 insertions, 50 deletions
diff --git a/include/attach.php b/include/attach.php
index 0f07fe035..0f31ed012 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -951,6 +951,9 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
call_hooks('photo_upload_end', $ret);
}
+ \Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $hash ]);
+
+
if($dosync) {
$sync = attach_export_data($channel,$hash);
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 21431e96f..f75ff2386 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -241,69 +241,84 @@ abstract class photo_driver {
}
+ /**
+ * @brief reads exif data from filename
+ */
+ public function exif($filename) {
- public function orient($filename) {
- /**
- * This function is a bit unusual, because it is operating on a file, but you must
- * first create an image from that file to initialise the type and check validity
- * of the image.
- */
-
- if(! $this->is_valid())
+ if((! function_exists('exif_read_data'))
+ || (! in_array($this->getType(), [ 'image/jpeg' , 'image/tiff'] ))) {
return false;
+ }
- if((! function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg'))
- return false;
-
- $exif = @exif_read_data($filename,null,true);
-
- if($exif) {
- $ort = $exif['IFD0']['Orientation'];
-
- switch($ort)
- {
- case 1: // nothing
- break;
+ /*
+ * PHP 7.2 allows you to use a stream resource, which should reduce/avoid
+ * memory exhaustion on large images.
+ */
- case 2: // horizontal flip
- $this->flip();
- break;
+ if(version_compare(PHP_VERSION,'7.2.0') >= 0) {
+ $f = @fopen($filename,'rb');
+ }
+ else {
+ $f = $filename;
+ }
- case 3: // 180 rotate left
- $this->rotate(180);
- break;
+ if($f) {
+ return @exif_read_data($f);
+ }
- case 4: // vertical flip
- $this->flip(false, true);
- break;
+ return false;
+ }
- case 5: // vertical flip + 90 rotate right
- $this->flip(false, true);
- $this->rotate(-90);
- break;
+ /**
+ * @brief orients current image based on exif orientation information
+ */
- case 6: // 90 rotate right
- $this->rotate(-90);
- break;
+ public function orient($exif) {
- case 7: // horizontal flip + 90 rotate right
- $this->flip();
- $this->rotate(-90);
- break;
+ if(! ($this->is_valid() && $exif)) {
+ return false;
+ }
- case 8: // 90 rotate left
- $this->rotate(90);
- break;
- }
+ $ort = $exif['IFD0']['Orientation'];
- return $exif;
+ if(! $ort) {
+ return false;
+ }
+ switch($ort) {
+ case 1: // nothing
+ break;
+ case 2: // horizontal flip
+ $this->flip();
+ break;
+ case 3: // 180 rotate left
+ $this->rotate(180);
+ break;
+ case 4: // vertical flip
+ $this->flip(false, true);
+ break;
+ case 5: // vertical flip + 90 rotate right
+ $this->flip(false, true);
+ $this->rotate(-90);
+ break;
+ case 6: // 90 rotate right
+ $this->rotate(-90);
+ break;
+ case 7: // horizontal flip + 90 rotate right
+ $this->flip();
+ $this->rotate(-90);
+ break;
+ case 8: // 90 rotate left
+ $this->rotate(90);
+ break;
+ default:
+ break;
}
-
- return false;
+ return true;
}
diff --git a/include/photos.php b/include/photos.php
index 41a1d18cb..b1391f284 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -203,7 +203,13 @@ function photo_upload($channel, $observer, $args) {
return $ret;
}
- $exif = $ph->orient(($args['os_syspath']) ? $args['os_syspath'] : $src);
+ // obtain exif data from the source file if present
+
+ $exif = $ph->exif(($args['os_syspath']) ? $args['os_syspath'] : $src);
+
+ if($exif) {
+ $ph->orient($exif);
+ }
@unlink($src);
diff --git a/include/text.php b/include/text.php
index ee8318d7c..343e3f00b 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2704,8 +2704,8 @@ function linkify_tags($a, &$body, $uid, $diaspora = false) {
function getIconFromType($type) {
$iconMap = array(
//Folder
- t('Collection') => 'fa-folder',
- 'multipart/mixed' => 'fa-folder', //dirs in attach use this mime type
+ t('Collection') => 'fa-folder-o',
+ 'multipart/mixed' => 'fa-folder-o', //dirs in attach use this mime type
//Common file
'application/octet-stream' => 'fa-file-o',
//Text