Merge pull request #559 from electerious/develop

Lychee 3.1.2
This commit is contained in:
Tobias Reich 2016-06-12 18:18:39 +02:00 committed by GitHub
commit 475ae5748b
12 changed files with 169 additions and 42 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -1,3 +1,13 @@
## v3.1.2
Released June 12, 2016
- `Improved` Added indexes to SQL fields to improve query execution time (Thanks @qligier, #533)
- `Improved` Protocol-relative URLs for open graph metadata (#546)
- `Improved` Remove metadata from medium-sized images and thumbnails (Imagick only) (#556)
- `Improved` Reduce quality of medium-sized images (Imagick only) (#556)
- `Improved` orientation-handling with Imagick (#556)
## v3.1.1 ## v3.1.1
Released April 30, 2016 Released April 30, 2016
@ -6,7 +16,7 @@ Released April 30, 2016
- `New` Import of IPTC photo tags (Thanks @qligier, #514) - `New` Import of IPTC photo tags (Thanks @qligier, #514)
- `New` Added reset username and password to FAQ (#500 #128) - `New` Added reset username and password to FAQ (#500 #128)
- `Improved` Removed will-change from the main image to improve the image rendering in Chrome (#501) - `Improved` Removed will-change from the main image to improve the image rendering in Chrome (#501)
- `Improved ` scroll and rendering performance by removing will-change - `Improved` scroll and rendering performance by removing will-change
- `Improved` Open Facebook and Twitter sharing sheet in new window - `Improved` Open Facebook and Twitter sharing sheet in new window
- `Improved` EXIF and IPTC extraction (Thanks @qligier, #518) - `Improved` EXIF and IPTC extraction (Thanks @qligier, #518)
- `Fixed` broken URL in Update.md (#516) - `Fixed` broken URL in Update.md (#516)

View File

@ -14,7 +14,8 @@ final class Database {
'030000', // 3.0.0 '030000', // 3.0.0
'030001', // 3.0.1 '030001', // 3.0.1
'030003', // 3.0.3 '030003', // 3.0.3
'030100' // 3.1.0 '030100', // 3.1.0
'030102' // 3.1.2
); );
/** /**

View File

@ -238,7 +238,6 @@ final class Photo {
} }
// Save to DB
$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); $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);
$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); $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);
$result = Database::execute(Database::get(), $query, __METHOD__, __LINE__); $result = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
@ -296,7 +295,7 @@ final class Photo {
Plugins::get()->activate(__METHOD__, 0, func_get_args()); Plugins::get()->activate(__METHOD__, 0, func_get_args());
// Quality of thumbnails // Quality of thumbnails
$thumbQuality = 90; $quality = 90;
// Size of the thumbnail // Size of the thumbnail
$newWidth = 200; $newWidth = 200;
@ -312,9 +311,12 @@ final class Photo {
// Read image // Read image
$thumb = new Imagick(); $thumb = new Imagick();
$thumb->readImage($url); $thumb->readImage($url);
$thumb->setImageCompressionQuality($thumbQuality); $thumb->setImageCompressionQuality($quality);
$thumb->setImageFormat('jpeg'); $thumb->setImageFormat('jpeg');
// Remove metadata to save some bytes
$thumb->stripImage();
// Copy image for 2nd thumb version // Copy image for 2nd thumb version
$thumb2x = clone $thumb; $thumb2x = clone $thumb;
@ -359,12 +361,12 @@ final class Photo {
// Create thumb // Create thumb
fastImageCopyResampled($thumb, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth, $newHeight, $newSize, $newSize); fastImageCopyResampled($thumb, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth, $newHeight, $newSize, $newSize);
imagejpeg($thumb, $newUrl, $thumbQuality); imagejpeg($thumb, $newUrl, $quality);
imagedestroy($thumb); imagedestroy($thumb);
// Create retina thumb // Create retina thumb
fastImageCopyResampled($thumb2x, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth*2, $newHeight*2, $newSize, $newSize); fastImageCopyResampled($thumb2x, $sourceImg, 0, 0, $startWidth, $startHeight, $newWidth*2, $newHeight*2, $newSize, $newSize);
imagejpeg($thumb2x, $newUrl2x, $thumbQuality); imagejpeg($thumb2x, $newUrl2x, $quality);
imagedestroy($thumb2x); imagedestroy($thumb2x);
// Free memory // Free memory
@ -395,6 +397,9 @@ final class Photo {
// Call plugins // Call plugins
Plugins::get()->activate(__METHOD__, 0, func_get_args()); Plugins::get()->activate(__METHOD__, 0, func_get_args());
// Quality of medium-photo
$quality = 90;
// Set to true when creation of medium-photo failed // Set to true when creation of medium-photo failed
$error = false; $error = false;
@ -427,6 +432,8 @@ final class Photo {
// Adjust image // Adjust image
$medium->scaleImage($newWidth, $newHeight, true); $medium->scaleImage($newWidth, $newHeight, true);
$medium->stripImage();
$medium->setImageCompressionQuality($quality);
// Save image // Save image
try { $medium->writeImage($newUrl); } try { $medium->writeImage($newUrl); }
@ -472,20 +479,50 @@ final class Photo {
if (extension_loaded('imagick')&&Settings::get()['imagick']==='1') { if (extension_loaded('imagick')&&Settings::get()['imagick']==='1') {
switch ($info['orientation']) { $image = new Imagick();
$image->readImage($path);
case 3: $orientation = $image->getImageOrientation();
$rotateImage = 180;
switch ($orientation) {
case Imagick::ORIENTATION_TOPLEFT:
return false;
break; break;
case 6: case Imagick::ORIENTATION_TOPRIGHT:
$rotateImage = 90; $image->flopImage();
$swapSize = true;
break; break;
case 8: case Imagick::ORIENTATION_BOTTOMRIGHT:
$rotateImage = 270; $image->rotateImage(new ImagickPixel(), 180);
$swapSize = true; break;
case Imagick::ORIENTATION_BOTTOMLEFT:
$image->flopImage();
$image->rotateImage(new ImagickPixel(), 180);
break;
case Imagick::ORIENTATION_LEFTTOP:
$image->flopImage();
$image->rotateImage(new ImagickPixel(), -90);
$swapSize = true;
break;
case Imagick::ORIENTATION_RIGHTTOP:
$image->rotateImage(new ImagickPixel(), 90);
$swapSize = true;
break;
case Imagick::ORIENTATION_RIGHTBOTTOM:
$image->flopImage();
$image->rotateImage(new ImagickPixel(), 90);
$swapSize = true;
break;
case Imagick::ORIENTATION_LEFTBOTTOM:
$image->rotateImage(new ImagickPixel(), -90);
$swapSize = true;
break; break;
default: default:
@ -494,15 +531,13 @@ final class Photo {
} }
if ($rotateImage!==0) { // Adjust photo
$image = new Imagick(); $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT);
$image->readImage($path); $image->writeImage($path);
$image->rotateImage(new ImagickPixel(), $rotateImage);
$image->setImageOrientation(1); // Free memory
$image->writeImage($path); $image->clear();
$image->clear(); $image->destroy();
$image->destroy();
}
} else { } else {
@ -512,6 +547,11 @@ final class Photo {
switch ($info['orientation']) { switch ($info['orientation']) {
case 1:
// do nothing
return false;
break;
case 2: case 2:
// mirror // mirror
// not yet implemented // not yet implemented
@ -561,6 +601,7 @@ final class Photo {
} }
// Recreate photo // Recreate photo
// In this step the photos also loses its metadata :(
$newSourceImg = imagecreatetruecolor($newWidth, $newHeight); $newSourceImg = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($newSourceImg, $sourceImg, 0, 0, 0, 0, $newWidth, $newHeight, $newWidth, $newHeight); imagecopyresampled($newSourceImg, $sourceImg, 0, 0, 0, 0, $newWidth, $newHeight, $newWidth, $newHeight);
imagejpeg($newSourceImg, $path, 100); imagejpeg($newSourceImg, $path, 100);

View File

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

View File

@ -7,6 +7,6 @@ CREATE TABLE IF NOT EXISTS `?` (
`type` varchar(11) NOT NULL, `type` varchar(11) NOT NULL,
`function` varchar(100) NOT NULL, `function` varchar(100) NOT NULL,
`line` int(11) NOT NULL, `line` int(11) NOT NULL,
`text` TEXT, `text` text,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -2,8 +2,8 @@
# ------------------------------------------------------------ # ------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `?` ( CREATE TABLE IF NOT EXISTS `?` (
`id` bigint(14) NOT NULL, `id` bigint(14) unsigned NOT NULL,
`title` varchar(100) NOT NULL, `title` varchar(100) NOT NULL DEFAULT '',
`description` varchar(1000) DEFAULT '', `description` varchar(1000) DEFAULT '',
`url` varchar(100) NOT NULL, `url` varchar(100) NOT NULL,
`tags` varchar(1000) NOT NULL DEFAULT '', `tags` varchar(1000) NOT NULL DEFAULT '',
@ -20,9 +20,11 @@ CREATE TABLE IF NOT EXISTS `?` (
`focal` varchar(20) NOT NULL, `focal` varchar(20) NOT NULL,
`takestamp` int(11) DEFAULT NULL, `takestamp` int(11) DEFAULT NULL,
`star` tinyint(1) NOT NULL, `star` tinyint(1) NOT NULL,
`thumbUrl` varchar(50) NOT NULL, `thumbUrl` char(37) NOT NULL,
`album` varchar(30) NOT NULL DEFAULT '0', `album` bigint(20) unsigned NOT NULL,
`checksum` VARCHAR(100) DEFAULT NULL, `checksum` char(40) DEFAULT NULL,
`medium` tinyint(1) NOT NULL DEFAULT '0', `medium` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; KEY `Index_album` (`album`),
KEY `Index_star` (`star`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -4,4 +4,4 @@
CREATE TABLE IF NOT EXISTS `?` ( CREATE TABLE IF NOT EXISTS `?` (
`key` varchar(50) NOT NULL DEFAULT '', `key` varchar(50) NOT NULL DEFAULT '',
`value` varchar(200) DEFAULT '' `value` varchar(200) DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -0,0 +1,73 @@
<?php
/**
* Update to version 3.1.2
*/
use Lychee\Modules\Database;
use Lychee\Modules\Response;
// Change type of the album id field
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `album` `album` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not change type of the album id field!');
// Add index to the album id field
$query = Database::prepare($connection, "SHOW INDEX FROM `?` WHERE KEY_NAME = 'Index_album'", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not check if Index_album exists!');
if ($result->num_rows===0) {
$query = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_album` (`album`)", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not add index to the album id field!');
}
// Add index to the star field
$query = Database::prepare($connection, "SHOW INDEX FROM `?` WHERE KEY_NAME = 'Index_star'", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not check if Index_star exists!');
if ($result->num_rows===0) {
$query = Database::prepare($connection, "ALTER TABLE `?` ADD INDEX `Index_star` (`star`)", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not add index to the star field!');
}
// Change type of the checksum field
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `checksum` `checksum` CHAR(40) NULL DEFAULT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not change type of the checksum field!');
// Change type of the thumbUrl field
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `thumbUrl` `thumbUrl` CHAR(37) NOT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not change type of the thumbUrl field!');
// Change type of the id field
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_PHOTOS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not change type of the id field!');
// Change type of the id field
$query = Database::prepare($connection, "ALTER TABLE `?` CHANGE `id` `id` BIGINT(14) UNSIGNED NOT NULL", array(LYCHEE_TABLE_ALBUMS));
$result = Database::execute($connection, $query, 'update_030102', __LINE__);
if ($result===false) Response::error('Could not change type of the id field!');
// Set version
if (Database::setVersion($connection, '030102')===false) Response::error('Could not update version of database!');
?>

View File

@ -24,8 +24,8 @@ function getGraphHeader($photoID) {
else $dir = 'big'; else $dir = 'big';
$parseUrl = parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $parseUrl = parse_url('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$url = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query']; $url = '//' . $parseUrl['host'] . $parseUrl['path'] . '?' . $parseUrl['query'];
$picture = $parseUrl['scheme'] . '://' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url; $picture = '//' . $parseUrl['host'] . $parseUrl['path'] . '/../uploads/' . $dir . '/' . $row->url;
$url = htmlentities($url); $url = htmlentities($url);
$picture = htmlentities($picture); $picture = htmlentities($picture);

View File

@ -1,6 +1,6 @@
{ {
"name": "Lychee", "name": "Lychee",
"version": "3.1.1", "version": "3.1.2",
"description": "Self-hosted photo-management done right.", "description": "Self-hosted photo-management done right.",
"authors": "Tobias Reich <tobias@electerious.com>", "authors": "Tobias Reich <tobias@electerious.com>",
"license": "MIT", "license": "MIT",

View File

@ -6,8 +6,8 @@
lychee = { lychee = {
title : document.title, title : document.title,
version : '3.1.1', version : '3.1.2',
versionCode : '030101', versionCode : '030102',
updatePath : '//update.electerious.com/index.json', updatePath : '//update.electerious.com/index.json',
updateURL : 'https://github.com/electerious/Lychee', updateURL : 'https://github.com/electerious/Lychee',