Changeset 13544 for trunk/include/ws_functions.inc.php
- Timestamp:
- Mar 13, 2012, 10:13:17 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/ws_functions.inc.php
r13090 r13544 220 220 $where_clauses = ws_std_image_sql_filter( $params, '' ); 221 221 $where_clauses[] = 'id<start_id'; 222 if ( !empty($params['ids']) ) 223 { 224 $where_clauses[] = 'id IN ('.implode(',',$params['ids']).')'; 225 } 222 226 223 227 $query_model = 'SELECT id, path, representative_ext, width, height … … 3267 3271 } 3268 3272 3269 function ws_images_resizethumbnail($params, &$service)3270 {3271 if (!is_admin())3272 {3273 return new PwgError(401, 'Access denied');3274 }3275 3276 if (empty($params['image_id']) and empty($params['image_path']))3277 {3278 return new PwgError(403, "image_id or image_path is missing");3279 }3280 3281 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');3282 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');3283 3284 if (!empty($params['image_id']))3285 {3286 $query='3287 SELECT id, path, tn_ext, has_high3288 FROM '.IMAGES_TABLE.'3289 WHERE id = '.(int)$params['image_id'].'3290 ;';3291 $image = pwg_db_fetch_assoc(pwg_query($query));3292 3293 if ($image == null)3294 {3295 return new PwgError(403, "image_id not found");3296 }3297 3298 $image_path = $image['path'];3299 $thumb_path = get_thumbnail_path($image);3300 }3301 else3302 {3303 $image_path = $params['image_path'];3304 $thumb_path = file_path_for_type($image_path, 'thumb');3305 }3306 3307 if (!file_exists($image_path) or !is_valid_image_extension(get_extension($image_path)))3308 {3309 return new PwgError(403, "image can't be resized");3310 }3311 3312 $result = false;3313 prepare_directory(dirname($thumb_path));3314 $img = new pwg_image($image_path, $params['library']);3315 3316 if (!is_bool($params['crop']))3317 $params['crop'] = get_boolean($params['crop']);3318 if (!is_bool($params['follow_orientation']))3319 $params['follow_orientation'] = get_boolean($params['follow_orientation']);3320 3321 $result = $img->pwg_resize(3322 $thumb_path,3323 $params['maxwidth'],3324 $params['maxheight'],3325 $params['quality'],3326 false, // automatic rotation is not needed for thumbnails.3327 true, // strip metadata3328 $params['crop'],3329 $params['follow_orientation']3330 );3331 3332 $img->destroy();3333 return $result;3334 }3335 3336 function ws_images_resizewebsize($params, &$service)3337 {3338 if (!is_admin())3339 {3340 return new PwgError(401, 'Access denied');3341 }3342 3343 include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');3344 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');3345 include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');3346 3347 $query='3348 SELECT id, path, tn_ext, has_high, width, height3349 FROM '.IMAGES_TABLE.'3350 WHERE id = '.(int)$params['image_id'].'3351 ;';3352 $image = pwg_db_fetch_assoc(pwg_query($query));3353 3354 if ($image == null)3355 {3356 return new PwgError(403, "image_id not found");3357 }3358 3359 $image_path = $image['path'];3360 3361 if (!is_valid_image_extension(get_extension($image_path)))3362 {3363 return new PwgError(403, "image can't be resized");3364 }3365 3366 $hd_path = get_high_path($image);3367 3368 if (empty($image['has_high']) or !file_exists($hd_path))3369 {3370 if ($image['width'] > $params['maxwidth'] or $image['height'] > $params['maxheight'])3371 {3372 $hd_path = file_path_for_type($image_path, 'high');3373 $hd_dir = dirname($hd_path);3374 prepare_directory($hd_dir);3375 3376 rename($image_path, $hd_path);3377 $hd_infos = pwg_image_infos($hd_path);3378 3379 single_update(3380 IMAGES_TABLE,3381 array(3382 'has_high' => 'true',3383 'high_filesize' => $hd_infos['filesize'],3384 'high_width' => $hd_infos['width'],3385 'high_height' => $hd_infos['height'],3386 ),3387 array(3388 'id' => $image['id']3389 )3390 );3391 }3392 else3393 {3394 return new PwgError(403, "image can't be resized");3395 }3396 }3397 3398 $result = false;3399 $img = new pwg_image($hd_path, $params['library']);3400 3401 $result = $img->pwg_resize(3402 $image_path,3403 $params['maxwidth'],3404 $params['maxheight'],3405 $params['quality'],3406 $params['automatic_rotation'],3407 false // strip metadata3408 );3409 3410 $img->destroy();3411 3412 global $conf;3413 $conf['use_exif'] = false;3414 $conf['use_iptc'] = false;3415 sync_metadata(array($image['id']));3416 3417 return $result;3418 }3419 3420 3273 function ws_extensions_update($params, &$service) 3421 3274 {
Note: See TracChangeset
for help on using the changeset viewer.