source: extensions/regenerateWebsize/ws_functions.inc.php @ 19183

Last change on this file since 19183 was 10442, checked in by patdenice, 14 years ago

Update some metadatas in database after resize.

File size: 1.5 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $conf;
6
7$service = &$arr[0];
8$service->addMethod(
9  'pwg.images.regenerateWebsize',
10  'ws_images_regenerateWebsize',
11  array(
12    'image_id'  => array(),
13    'maxwidth'  => array('default'=>$conf['upload_form_websize_maxwidth']),
14    'maxheight' => array('default'=>$conf['upload_form_websize_maxheight']),
15    'quality'   => array('default'=>$conf['upload_form_websize_quality']),
16  ),
17  'Regenerate websize images from HD with given arguments.'
18);
19
20function ws_images_regenerateWebsize($params, &$service)
21{
22  global $conf;
23
24  if (!is_admin())
25    return new PwgError(401, 'Access denied');
26
27  $query='
28SELECT id, path, has_high, width, height
29FROM '.IMAGES_TABLE.'
30WHERE id = '.(int)$params['image_id'].'
31;';
32
33  $image = pwg_db_fetch_assoc(pwg_query($query));
34  if ($image == null)
35    return new PwgError(404, "image_id not found");
36
37  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
38
39  if (!empty( $image['has_high'] ))
40  {
41    trigger_event(
42      'upload_image_resize',
43      false,
44      file_path_for_type($image['path'], 'high'),
45      $image['path'],
46      $params['maxwidth'],
47      $params['maxheight'],
48      $params['quality'],
49      false
50      );
51
52    $conf['use_exif'] = false;
53    $conf['use_iptc'] = false;
54    update_metadata(array($image['id'] => $image['path']));
55
56    return true;
57  }
58
59  return false;
60}
61
62?>
Note: See TracBrowser for help on using the repository browser.