Index: /trunk/ws.php
===================================================================
--- /trunk/ws.php	(revision 10684)
+++ /trunk/ws.php	(revision 10686)
@@ -406,23 +406,33 @@
 
   $service->addMethod(
-    'pwg.images.resize',
-    'ws_images_resize',
+    'pwg.images.resizeThumbnail',
+    'ws_images_resizethumbnail',
     array(
       'image_id' => array('default' => null),
       'image_path' => array('default' => null),
-      'type' => array('default' => 'thumbnail'),
+      'maxwidth' => array('default' => $conf['upload_form_thumb_maxwidth']),
+      'maxheight' => array('default' => $conf['upload_form_thumb_maxheight']),
+      'quality' => array('default' => $conf['upload_form_thumb_quality']),
+      'crop' => array('default' => $conf['upload_form_thumb_crop']),
+      'follow_orientation' => array('default' => $conf['upload_form_thumb_follow_orientation']),
+      'library' => array('default' => $conf['graphics_library']),
+    ),
+    'Create/Regenerate thumbnails photo with given arguments.
+<br>One of arguments "image_id" or "image_path" must be sent.'
+  );
+
+  $service->addMethod(
+    'pwg.images.resizeWebsize',
+    'ws_images_resizewebsize',
+    array(
+      'image_id' => array(),
+      'maxwidth' => array('default' => $conf['upload_form_websize_maxwidth']),
+      'maxheight' => array('default' => $conf['upload_form_websize_maxheight']),
+      'quality' => array('default' => $conf['upload_form_websize_quality']),
       'automatic_rotation' => array('default' => $conf['upload_form_automatic_rotation']),
       'library' => array('default' => $conf['graphics_library']),
-      'maxwidth' => array('default' => null),
-      'maxheight' => array('default' => null),
-      'crop' => array('default' => null),
-      'follow_orientation' => array('default' => null),
-      'quality' => array('default' => null),
     ),
-    'Create/Regenerate thumbnails or websize photo with given arguments.
-<br>One of arguments "image_id" or "image_path" must be passed filled.
-<br>Argument "type" can be "thumbnail" or "websize". Default is "thumbnail".
-<br>If maxwidth, maxheight, crop, follow_orientation or quality are missing, default parameters of upload will be used.'
-);
+    'Regenerate websize photo with given arguments.'
+  );
 
   $service->addMethod(
Index: /trunk/include/ws_functions.inc.php
===================================================================
--- /trunk/include/ws_functions.inc.php	(revision 10653)
+++ /trunk/include/ws_functions.inc.php	(revision 10686)
@@ -2659,8 +2659,6 @@
 }
 
-function ws_images_resize($params, &$service)
-{
-  global $conf;
-
+function ws_images_resizethumbnail($params, &$service)
+{
   if (!is_admin())
   {
@@ -2668,9 +2666,4 @@
   }
 
-  if (!in_array($params['type'], array('thumbnail', 'websize')))
-  {
-    return new PwgError(403, 'Unknown type (only "thumbnail" or "websize" are accepted');
-  }
-
   if (empty($params['image_id']) and empty($params['image_path']))
   {
@@ -2678,13 +2671,4 @@
   }
 
-  $resize_params = array('maxwidth', 'maxheight', 'quality', 'crop', 'follow_orientation');
-  $type = $params['type'] == 'thumbnail' ? 'thumb' : 'websize';
-  foreach ($resize_params as $param)
-  {
-    if (empty($params[$param]) and isset($conf['upload_form_'.$type.'_'.$param]))
-      $params[$param] = $conf['upload_form_'.$type.'_'.$param];
-  }
-
-  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
   include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
   include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
@@ -2706,5 +2690,4 @@
     $image_path = $image['path'];
     $thumb_path = get_thumbnail_path($image);
-    $hd_path = get_high_path($image);
   }
   else
@@ -2712,8 +2695,7 @@
     $image_path = $params['image_path'];
     $thumb_path = file_path_for_type($image_path, 'thumb');
-    $hd_path = file_path_for_type($image_path, 'high');
-  }
-
-  if (!is_valid_image_extension(get_extension($image_path)))
+  }
+
+  if (!file_exists($image_path) or !is_valid_image_extension(get_extension($image_path)))
   {
     return new PwgError(403, "image can't be resized");
@@ -2721,46 +2703,72 @@
 
   $result = false;
-
-  if ($params['type'] == 'thumbnail' and file_exists($image_path))
-  {
-    prepare_directory(dirname($thumb_path));
-
-    $img = new pwg_image($image_path, $params['library']);
-
-    $result =  $img->pwg_resize(
-      $thumb_path,
-      $params['maxwidth'],
-      $params['maxheight'],
-      $params['quality'],
-      $params['automatic_rotation'],
-      true,
-      get_boolean($params['crop']),
-      get_boolean($params['follow_orientation'])
-    );
-
-    $img->destroy();
-  }
-  elseif (file_exists($hd_path))
-  {
-    $img = new pwg_image($hd_path);
-
-    $result = $img->pwg_resize(
-      $image_path,
-      $params['maxwidth'],
-      $params['maxheight'],
-      $params['quality'],
-      $params['automatic_rotation'],
-      false
-      );
-
-    $img->destroy();
-
-    if (!empty($image['has_high']))
-    {
-      $conf['use_exif'] = false;
-      $conf['use_iptc'] = false;
-      update_metadata(array($image['id'] => $image['path']));
-    }
-  }
+  prepare_directory(dirname($thumb_path));
+  $img = new pwg_image($image_path, $params['library']);
+
+  $result =  $img->pwg_resize(
+    $thumb_path,
+    $params['maxwidth'],
+    $params['maxheight'],
+    $params['quality'],
+    false, // automatic rotation is not needed for thumbnails.
+    true, // strip metadata
+    get_boolean($params['crop']),
+    get_boolean($params['follow_orientation'])
+  );
+
+  $img->destroy();
+  return $result;
+}
+
+function ws_images_resizewebsize($params, &$service)
+{
+  if (!is_admin())
+  {
+    return new PwgError(401, 'Access denied');
+  }
+
+  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
+  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
+  include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
+
+  $query='
+SELECT id, path, tn_ext, has_high
+  FROM '.IMAGES_TABLE.'
+  WHERE id = '.(int)$params['image_id'].'
+;';
+  $image = pwg_db_fetch_assoc(pwg_query($query));
+
+  if ($image == null)
+  {
+    return new PwgError(403, "image_id not found");
+  }
+
+  $image_path = $image['path'];
+  $hd_path = get_high_path($image);
+
+  if (empty($image['has_high']) or !file_exists($hd_path) or !is_valid_image_extension(get_extension($image_path)))
+  {
+    return new PwgError(403, "image can't be resized");
+  }
+
+  $result = false;
+  $img = new pwg_image($hd_path);
+
+  $result = $img->pwg_resize(
+    $image_path,
+    $params['maxwidth'],
+    $params['maxheight'],
+    $params['quality'],
+    $params['automatic_rotation'],
+    false // strip metadata
+    );
+
+  $img->destroy();
+
+  global $conf;
+  $conf['use_exif'] = false;
+  $conf['use_iptc'] = false;
+  update_metadata(array($image['id'] => $image['path']));
+
   return $result;
 }
Index: /trunk/admin/themes/default/template/thumbnail.tpl
===================================================================
--- /trunk/admin/themes/default/template/thumbnail.tpl	(revision 10571)
+++ /trunk/admin/themes/default/template/thumbnail.tpl	(revision 10686)
@@ -31,7 +31,6 @@
       url: 'ws.php', 
       data: {
-        method: 'pwg.images.resize',
+        method: 'pwg.images.resizeThumbnail',
         image_path: image_path,
-        type: 'thumbnail',
         maxwidth: width,
         maxheight: height,
Index: /trunk/admin/themes/default/template/batch_manager_global.tpl
===================================================================
--- /trunk/admin/themes/default/template/batch_manager_global.tpl	(revision 10637)
+++ /trunk/admin/themes/default/template/batch_manager_global.tpl	(revision 10686)
@@ -334,5 +334,5 @@
     else if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails')
     {
-      type = 'thumbnail';
+      resizeMethod = 'pwg.images.resizeThumbnail';
       maxRequests = 3;
       maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
@@ -344,5 +344,5 @@
     else if(jQuery('[name="selectAction"]').val() == 'regenerateWebsize')
     {
-      type = 'websize';
+      resizeMethod = 'pwg.images.resizeWebsize';
       maxRequests = 1;
       maxwidth = jQuery('input[name="websize_maxwidth"]').val();
@@ -391,6 +391,5 @@
         url: 'ws.php', 
         data: {
-          method: 'pwg.images.resize',
-          type: type,
+          method: resizeMethod,
           maxwidth: maxwidth,
           maxheight: maxheight,
Index: /trunk/admin/include/image.class.php
===================================================================
--- /trunk/admin/include/image.class.php	(revision 10684)
+++ /trunk/admin/include/image.class.php	(revision 10686)
@@ -291,5 +291,5 @@
     if (is_null($library))
     {
-      $library = $conf['image_library'];
+      $library = $conf['graphics_library'];
     }
 
