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

Last change on this file since 10382 was 10382, checked in by patdenice, 13 years ago

Don't strip metadata while regenerate websize pictures.

File size: 1.3 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    return true;
53  }
54
55  return false;
56}
57
58?>
Note: See TracBrowser for help on using the repository browser.