Skip to content

Commit 475ae57

Browse files
authored
Merge pull request #559 from electerious/develop
Lychee 3.1.2
2 parents 75b11ac + 8c279a5 commit 475ae57

12 files changed

+170
-43
lines changed

dist/main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Changelog.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v3.1.2
2+
3+
Released June 12, 2016
4+
5+
- `Improved` Added indexes to SQL fields to improve query execution time (Thanks @qligier, #533)
6+
- `Improved` Protocol-relative URLs for open graph metadata (#546)
7+
- `Improved` Remove metadata from medium-sized images and thumbnails (Imagick only) (#556)
8+
- `Improved` Reduce quality of medium-sized images (Imagick only) (#556)
9+
- `Improved` orientation-handling with Imagick (#556)
10+
111
## v3.1.1
212

313
Released April 30, 2016
@@ -6,7 +16,7 @@ Released April 30, 2016
616
- `New` Import of IPTC photo tags (Thanks @qligier, #514)
717
- `New` Added reset username and password to FAQ (#500 #128)
818
- `Improved` Removed will-change from the main image to improve the image rendering in Chrome (#501)
9-
- `Improved ` scroll and rendering performance by removing will-change
19+
- `Improved` scroll and rendering performance by removing will-change
1020
- `Improved` Open Facebook and Twitter sharing sheet in new window
1121
- `Improved` EXIF and IPTC extraction (Thanks @qligier, #518)
1222
- `Fixed` broken URL in Update.md (#516)

php/Modules/Database.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ final class Database {
1414
'030000', // 3.0.0
1515
'030001', // 3.0.1
1616
'030003', // 3.0.3
17-
'030100' // 3.1.0
17+
'030100', // 3.1.0
18+
'030102' // 3.1.2
1819
);
1920

2021
/**

php/Modules/Photo.php

+64-23
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ public function add(array $files, $albumID = 0, $returnOnError = false) {
238238

239239
}
240240

241-
// Save to DB
242241
$values = array(LYCHEE_TABLE_PHOTOS, $id, $info['title'], $photo_name, $info['description'], $info['tags'], $info['type'], $info['width'], $info['height'], $info['size'], $info['iso'], $info['aperture'], $info['make'], $info['model'], $info['shutter'], $info['focal'], $info['takestamp'], $path_thumb, $albumID, $public, $star, $checksum, $medium);
243242
$query = Database::prepare(Database::get(), "INSERT INTO ? (id, title, url, description, tags, type, width, height, size, iso, aperture, make, model, shutter, focal, takestamp, thumbUrl, album, public, star, checksum, medium) VALUES ('?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?')", $values);
244243
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
@@ -296,7 +295,7 @@ private function createThumb($url, $filename, $type, $width, $height) {
296295
Plugins::get()->activate(__METHOD__, 0, func_get_args());
297296

298297
// Quality of thumbnails
299-
$thumbQuality = 90;
298+
$quality = 90;
300299

301300
// Size of the thumbnail
302301
$newWidth = 200;
@@ -312,9 +311,12 @@ private function createThumb($url, $filename, $type, $width, $height) {
312311
// Read image
313312
$thumb = new Imagick();
314313
$thumb->readImage($url);
315-
$thumb->setImageCompressionQuality($thumbQuality);
314+
$thumb->setImageCompressionQuality($quality);
316315
$thumb->setImageFormat('jpeg');
317316

317+
// Remove metadata to save some bytes
318+
$thumb->stripImage();
319+
318320
// Copy image for 2nd thumb version
319321
$thumb2x = clone $thumb;
320322

@@ -359,12 +361,12 @@ private function createThumb($url, $filename, $type, $width, $height) {
359361

360362
// Create thumb
361363
fastImageCopyResampled($thumb, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth, $newHeight, $newSize, $newSize);
362-
imagejpeg($thumb, $newUrl, $thumbQuality);
364+
imagejpeg($thumb, $newUrl, $quality);
363365
imagedestroy($thumb);
364366

365367
// Create retina thumb
366368
fastImageCopyResampled($thumb2x, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth*2, $newHeight*2, $newSize, $newSize);
367-
imagejpeg($thumb2x, $newUrl2x, $thumbQuality);
369+
imagejpeg($thumb2x, $newUrl2x, $quality);
368370
imagedestroy($thumb2x);
369371

370372
// Free memory
@@ -395,6 +397,9 @@ private function createMedium($url, $filename, $width, $height) {
395397
// Call plugins
396398
Plugins::get()->activate(__METHOD__, 0, func_get_args());
397399

400+
// Quality of medium-photo
401+
$quality = 90;
402+
398403
// Set to true when creation of medium-photo failed
399404
$error = false;
400405

@@ -427,6 +432,8 @@ private function createMedium($url, $filename, $width, $height) {
427432

428433
// Adjust image
429434
$medium->scaleImage($newWidth, $newHeight, true);
435+
$medium->stripImage();
436+
$medium->setImageCompressionQuality($quality);
430437

431438
// Save image
432439
try { $medium->writeImage($newUrl); }
@@ -472,20 +479,50 @@ public function adjustFile($path, array $info) {
472479

473480
if (extension_loaded('imagick')&&Settings::get()['imagick']==='1') {
474481

475-
switch ($info['orientation']) {
482+
$image = new Imagick();
483+
$image->readImage($path);
476484

477-
case 3:
478-
$rotateImage = 180;
485+
$orientation = $image->getImageOrientation();
486+
487+
switch ($orientation) {
488+
489+
case Imagick::ORIENTATION_TOPLEFT:
490+
return false;
479491
break;
480492

481-
case 6:
482-
$rotateImage = 90;
483-
$swapSize = true;
493+
case Imagick::ORIENTATION_TOPRIGHT:
494+
$image->flopImage();
484495
break;
485496

486-
case 8:
487-
$rotateImage = 270;
488-
$swapSize = true;
497+
case Imagick::ORIENTATION_BOTTOMRIGHT:
498+
$image->rotateImage(new ImagickPixel(), 180);
499+
break;
500+
501+
case Imagick::ORIENTATION_BOTTOMLEFT:
502+
$image->flopImage();
503+
$image->rotateImage(new ImagickPixel(), 180);
504+
break;
505+
506+
case Imagick::ORIENTATION_LEFTTOP:
507+
$image->flopImage();
508+
$image->rotateImage(new ImagickPixel(), -90);
509+
$swapSize = true;
510+
break;
511+
512+
case Imagick::ORIENTATION_RIGHTTOP:
513+
$image->rotateImage(new ImagickPixel(), 90);
514+
$swapSize = true;
515+
break;
516+
517+
case Imagick::ORIENTATION_RIGHTBOTTOM:
518+
$image->flopImage();
519+
$image->rotateImage(new ImagickPixel(), 90);
520+
$swapSize = true;
521+
break;
522+
523+
case Imagick::ORIENTATION_LEFTBOTTOM:
524+
$image->rotateImage(new ImagickPixel(), -90);
525+
$swapSize = true;
489526
break;
490527

491528
default:
@@ -494,15 +531,13 @@ public function adjustFile($path, array $info) {
494531

495532
}
496533

497-
if ($rotateImage!==0) {
498-
$image = new Imagick();
499-
$image->readImage($path);
500-
$image->rotateImage(new ImagickPixel(), $rotateImage);
501-
$image->setImageOrientation(1);
502-
$image->writeImage($path);
503-
$image->clear();
504-
$image->destroy();
505-
}
534+
// Adjust photo
535+
$image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
536+
$image->writeImage($path);
537+
538+
// Free memory
539+
$image->clear();
540+
$image->destroy();
506541

507542
} else {
508543

@@ -512,6 +547,11 @@ public function adjustFile($path, array $info) {
512547

513548
switch ($info['orientation']) {
514549

550+
case 1:
551+
// do nothing
552+
return false;
553+
break;
554+
515555
case 2:
516556
// mirror
517557
// not yet implemented
@@ -561,6 +601,7 @@ public function adjustFile($path, array $info) {
561601
}
562602

563603
// Recreate photo
604+
// In this step the photos also loses its metadata :(
564605
$newSourceImg = imagecreatetruecolor($newWidth, $newHeight);
565606
imagecopyresampled($newSourceImg, $sourceImg, 0, 0, 0, 0, $newWidth, $newHeight, $newWidth, $newHeight);
566607
imagejpeg($newSourceImg, $path, 100);

php/database/albums_table.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ------------------------------------------------------------
33

44
CREATE TABLE IF NOT EXISTS `?` (
5-
`id` bigint(14) NOT NULL,
5+
`id` bigint(14) unsigned NOT NULL,
66
`title` varchar(100) NOT NULL DEFAULT '',
77
`description` varchar(1000) DEFAULT '',
88
`sysstamp` int(11) NOT NULL,
@@ -11,4 +11,4 @@ CREATE TABLE IF NOT EXISTS `?` (
1111
`downloadable` tinyint(1) NOT NULL DEFAULT '0',
1212
`password` varchar(100) DEFAULT NULL,
1313
PRIMARY KEY (`id`)
14-
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
14+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

php/database/log_table.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ CREATE TABLE IF NOT EXISTS `?` (
77
`type` varchar(11) NOT NULL,
88
`function` varchar(100) NOT NULL,
99
`line` int(11) NOT NULL,
10-
`text` TEXT,
10+
`text` text,
1111
PRIMARY KEY (`id`)
12-
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
12+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

php/database/photos_table.sql

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# ------------------------------------------------------------
33

44
CREATE TABLE IF NOT EXISTS `?` (
5-
`id` bigint(14) NOT NULL,
6-
`title` varchar(100) NOT NULL,
5+
`id` bigint(14) unsigned NOT NULL,
6+
`title` varchar(100) NOT NULL DEFAULT '',
77
`description` varchar(1000) DEFAULT '',
88
`url` varchar(100) NOT NULL,
99
`tags` varchar(1000) NOT NULL DEFAULT '',
@@ -20,9 +20,11 @@ CREATE TABLE IF NOT EXISTS `?` (
2020
`focal` varchar(20) NOT NULL,
2121
`takestamp` int(11) DEFAULT NULL,
2222
`star` tinyint(1) NOT NULL,
23-
`thumbUrl` varchar(50) NOT NULL,
24-
`album` varchar(30) NOT NULL DEFAULT '0',
25-
`checksum` VARCHAR(100) DEFAULT NULL,
23+
`thumbUrl` char(37) NOT NULL,
24+
`album` bigint(20) unsigned NOT NULL,
25+
`checksum` char(40) DEFAULT NULL,
2626
`medium` tinyint(1) NOT NULL DEFAULT '0',
27-
PRIMARY KEY (`id`)
28-
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
27+
PRIMARY KEY (`id`),
28+
KEY `Index_album` (`album`),
29+
KEY `Index_star` (`star`)
30+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

php/database/settings_table.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
CREATE TABLE IF NOT EXISTS `?` (
55
`key` varchar(50) NOT NULL DEFAULT '',
66
`value` varchar(200) DEFAULT ''
7-
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
7+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

php/database/update_030102.php

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
/**
4+
* Update to version 3.1.2
5+
*/
6+
7+
use Lychee\Modules\Database;
8+
use Lychee\Modules\Response;
9+
10+
// Change type of the album id field
11+
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `album` `album` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
12+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
13+
14+
if ($result===false) Response::error('Could not change type of the album id field!');
15+
16+
// Add index to the album id field
17+
$query = Database::prepare($connection, "SHOW INDEX FROM `?` WHERE KEY_NAME = 'Index_album'", array(LYCHEE_TABLE_PHOTOS));
18+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
19+
20+
if ($result===false) Response::error('Could not check if Index_album exists!');
21+
22+
if ($result->num_rows===0) {
23+
24+
$query = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_album` (`album`)", array(LYCHEE_TABLE_PHOTOS));
25+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
26+
27+
if ($result===false) Response::error('Could not add index to the album id field!');
28+
29+
}
30+
31+
// Add index to the star field
32+
$query = Database::prepare($connection, "SHOW INDEX FROM `?` WHERE KEY_NAME = 'Index_star'", array(LYCHEE_TABLE_PHOTOS));
33+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
34+
35+
if ($result===false) Response::error('Could not check if Index_star exists!');
36+
37+
if ($result->num_rows===0) {
38+
39+
$query = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_star` (`star`)", array(LYCHEE_TABLE_PHOTOS));
40+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
41+
42+
if ($result===false) Response::error('Could not add index to the star field!');
43+
44+
}
45+
46+
// Change type of the checksum field
47+
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `checksum` `checksum` CHAR(40) NULL DEFAULT NULL", array(LYCHEE_TABLE_PHOTOS));
48+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
49+
50+
if ($result===false) Response::error('Could not change type of the checksum field!');
51+
52+
// Change type of the thumbUrl field
53+
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `thumbUrl` `thumbUrl` CHAR(37) NOT NULL", array(LYCHEE_TABLE_PHOTOS));
54+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
55+
56+
if ($result===false) Response::error('Could not change type of the thumbUrl field!');
57+
58+
// Change type of the id field
59+
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
60+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
61+
62+
if ($result===false) Response::error('Could not change type of the id field!');
63+
64+
// Change type of the id field
65+
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_ALBUMS));
66+
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
67+
68+
if ($result===false) Response::error('Could not change type of the id field!');
69+
70+
// Set version
71+
if (Database::setVersion($connection, '030102')===false) Response::error('Could not update version of database!');
72+
73+
?>

php/helpers/getGraphHeader.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function getGraphHeader($photoID) {
2424
else $dir = 'big';
2525

2626
$parseUrl = parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
27-
$url = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query'];
28-
$picture = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url;
27+
$url = '//' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query'];
28+
$picture = '//' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url;
2929

3030
$url = htmlentities($url);
3131
$picture = htmlentities($picture);

src/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Lychee",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "Self-hosted photo-management done right.",
55
"authors": "Tobias Reich <[email protected]>",
66
"license": "MIT",

src/scripts/lychee.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
lychee = {
77

88
title : document.title,
9-
version : '3.1.1',
10-
versionCode : '030101',
9+
version : '3.1.2',
10+
versionCode : '030102',
1111

1212
updatePath : '//update.electerious.com/index.json',
1313
updateURL : 'https://github.com/electerious/Lychee',

0 commit comments

Comments
 (0)