aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2008-10-05 21:22:57 +0000
committerplegall <plg@piwigo.org>2008-10-05 21:22:57 +0000
commitb53cddbf6ae1eb70170dd8a31e3cba879929797e (patch)
tree2ccc44d984766b06f849edbaf79666ca9b4afe99 /include
parent0bdc6a5dac8ee12cf630b42e4a8d6a0be4116ae2 (diff)
feature 885 added: pwg.images.add web API method now supports additional
high resolution format. git-svn-id: http://piwigo.org/svn/trunk@2670 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php45
1 files changed, 41 insertions, 4 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 31167e1ad..c2e8c1778 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -950,7 +950,7 @@ SELECT
// check dumped file md5sum against expected md5sum
$dumped_md5 = md5_file($file_path);
if ($dumped_md5 != $params['file_sum']) {
- return new PwgError(500, 'file transfert failed');
+ return new PwgError(500, 'file transfer failed');
}
// thumbnail directory is a subdirectory of the photo file, hard coded
@@ -980,11 +980,42 @@ SELECT
// check dumped thumbnail md5
$dumped_md5 = md5_file($thumbnail_path);
if ($dumped_md5 != $params['thumbnail_sum']) {
- return new PwgError(500, 'thumbnail transfert failed');
+ return new PwgError(500, 'thumbnail transfer failed');
}
- // fwrite($fh_log, 'output: '.md5_file($file_path)."\n");
- // fwrite($fh_log, 'output: '.md5_file($thumbnail_path)."\n");
+ // high resolution
+ if (isset($params['high_content']))
+ {
+ // high resolution directory is a subdirectory of the photo file, hard
+ // coded "pwg_high"
+ $high_dir = $upload_dir.'/pwg_high';
+ if (!is_dir($high_dir)) {
+ umask(0000);
+ mkdir($high_dir, 0777);
+ }
+
+ // high resolution path, same name as web size file
+ $high_path = sprintf(
+ '%s/%s.%s',
+ $high_dir,
+ $filename_wo_ext,
+ 'jpg'
+ );
+
+ // dump the high resolution file
+ $fh_high = fopen($high_path, 'w');
+ fwrite($fh_high, base64_decode($params['high_content']));
+ fclose($fh_high);
+ chmod($high_path, 0644);
+
+ // check dumped thumbnail md5
+ $dumped_md5 = md5_file($high_path);
+ if ($dumped_md5 != $params['high_sum']) {
+ return new PwgError(500, 'high resolution transfer failed');
+ }
+
+ $high_filesize = floor(filesize($high_path)/1024);
+ }
list($width, $height) = getimagesize($file_path);
@@ -1017,6 +1048,12 @@ SELECT
}
}
+ if (isset($params['high_content']))
+ {
+ $insert['has_high'] = 'true';
+ $insert['high_filesize'] = $high_filesize;
+ }
+
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
mass_inserts(
IMAGES_TABLE,