diff options
| author | Marcin Łabanowski <marcin@6irc.net> | 2013-01-23 18:58:38 +0100 |
|---|---|---|
| committer | Marcin Łabanowski <marcin@6irc.net> | 2013-01-23 18:58:38 +0100 |
| commit | fabba73ce4008faa6c5f09f331786afd4f029020 (patch) | |
| tree | 0ffb1d00c418a02c49e3edbef600dbc38bd5d9d2 /post.php | |
| parent | e087e9afae07ec2249dc8d11ab223da2c5a9b04c (diff) | |
| parent | 85578b7105f7b53e0f45fc886270540b9d07b2f3 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard into HEAD
Conflicts:
mod.php
Diffstat (limited to 'post.php')
| -rw-r--r-- | post.php | 75 |
1 files changed, 75 insertions, 0 deletions
@@ -427,6 +427,81 @@ if (isset($_POST['delete'])) { error($config['error']['maxsize']); } + // The following code corrects the image orientation based on EXIF. + // Currently only works with the 'convert' option selected but it could easily be expanded to work with the rest if you can be bothered. + if ($config['thumb_method'] == 'convert') { + if ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg') { + $exif = exif_read_data($upload); + if (isset($exif['Orientation'])) { + switch($exif['Orientation']) { + case 1: + // Normal + $args = false; + break; + case 2: + // 888888 + // 88 + // 8888 + // 88 + // 88 + + $args = '-flop'; + break; + case 3: + + // 88 + // 88 + // 8888 + // 88 + // 888888 + + $args = '-flip -flop'; + break; + case 4: + // 88 + // 88 + // 8888 + // 88 + // 888888 + + $args = '-flip'; + break; + case 5: + // 8888888888 + // 88 88 + // 88 + + $args = '-rotate 90 -flop'; + break; + case 6: + // 88 + // 88 88 + // 8888888888 + + $args = '-rotate 90'; + break; + case 7: + // 88 + // 88 88 + // 8888888888 + + $args = '-rotate "-90" -flop'; + break; + case 8: + // 8888888888 + // 88 88 + // 88 + + $args = '-rotate "-90"'; + break; + } + + if ($args) + shell_exec('convert ' . escapeshellarg($upload) . ' ' . $args . ' ' . escapeshellarg($upload)); + } + } + } + // create image object $image = new Image($upload, $post['extension']); |
