Permalink
Browse files

If -blur is used without -filter, default to "-filter gaussian"

  • Loading branch information...
1 parent dea09d1 commit 09c4f6f56026426aa2a1fd24eccac4c4c65783ef @jsummers committed Sep 19, 2012
Showing with 21 additions and 10 deletions.
  1. +1 −0 changelog.txt
  2. +1 −1 readme.txt
  3. +18 −8 src/imagew-cmd.c
  4. +1 −1 tests/runtest
View
1 changelog.txt
@@ -1,4 +1,5 @@
Unreleased changes
+ - If -blur is used without -filter, default to "-filter gaussian".
- Added -s and -S options.
- Removed the --with-sample-depth configuration option.
- Removed CMake support.
View
2 readme.txt
@@ -301,7 +301,7 @@ Options:
Adjust the width of the resampling filter.
This is really a parameter of the resampling filter: if you use -blur,
- you must also use -filter. "-blur" does not work with some algorithms,
+ you should also use -filter. "-blur" does not work with some algorithms,
such as "nearest".
The default value is 1.0. Larger values blur the image more. A value
View
26 src/imagew-cmd.c
@@ -56,8 +56,9 @@ struct resize_alg {
};
struct resize_blur {
+ int is_set; // Did the user set this blur option?
double blur;
- int interpolate; // If set, muliply 'blur' by the scaling factor (if downscaling)
+ int interpolate; // If set, multiply 'blur' by the scaling factor (if downscaling)
};
struct dither_setting {
@@ -949,6 +950,7 @@ static int iwcmd_run(struct params_struct *p)
const char *s;
unsigned int profile;
int k;
+ int tmpflag;
memset(&init_params,0,sizeof(struct iw_init_params));
memset(&readdescr,0,sizeof(struct iw_iodescr));
@@ -1188,6 +1190,20 @@ static int iwcmd_run(struct params_struct *p)
if(p->translate_x!=0.0) iw_set_value_dbl(ctx,IW_VAL_TRANSLATE_X,p->translate_x);
if(p->translate_y!=0.0) iw_set_value_dbl(ctx,IW_VAL_TRANSLATE_Y,p->translate_y);
+ tmpflag = 0; // Have we displayed a "gaussian filter" warning yet?
+ if(p->resize_blur_x.is_set && !p->resize_alg_x.family) {
+ if(!p->nowarn) {
+ iwcmd_warning(p,"Notice: Selecting gaussian filter for blurring\n");
+ tmpflag = 1;
+ }
+ p->resize_alg_x.family = IW_RESIZETYPE_GAUSSIAN;
+ }
+ if(p->resize_blur_y.is_set && !p->resize_alg_y.family) {
+ if(!p->nowarn && !tmpflag) {
+ iwcmd_warning(p,"Notice: Selecting gaussian filter for blurring\n");
+ }
+ p->resize_alg_y.family = IW_RESIZETYPE_GAUSSIAN;
+ }
// Wait until we know the target image size to set the resize algorithm, so
// that we can support our "interpolate" option.
@@ -1205,13 +1221,6 @@ static int iwcmd_run(struct params_struct *p)
iwcmd_set_resize(ctx,IW_DIMENSION_V,&p->resize_alg_y,&p->resize_blur_y);
}
- if( (!p->resize_alg_x.family && (p->resize_blur_x.blur!=1.0 || p->resize_blur_x.interpolate)) ||
- (!p->resize_alg_y.family && (p->resize_blur_y.blur!=1.0 || p->resize_blur_y.interpolate)) )
- {
- if(!p->nowarn)
- iwcmd_warning(p,"Warning: -blur option requires -filter\n");
- }
-
if(p->noinfo) {
;
}
@@ -1645,6 +1654,7 @@ static int iwcmd_decode_blur_option(struct params_struct *p,
{
int namelen;
+ rblur->is_set = 1;
namelen=iwcmd_get_name_len(s);
if(namelen==1 && !strncmp(s,"x",namelen)) {
View
2 tests/runtest
@@ -157,7 +157,7 @@ $IW srcimg/4x4.png actual/intclamp.png $DCMPR $SCALE -filter lanczos -intclamp
$IW srcimg/4x4.png actual/grayscale.png $DCMPR $SCALE -filter catrom -grayscale
$IW srcimg/4x4.png actual/grayscale-c.png $DCMPR $SCALE -filter catrom -nogamma -grayscaleformula c
$IW srcimg/4x4.png actual/grayscale-w.png $CMPR $SCALE -filter quadratic -gsf w3,7,1
-$IW srcimg/4x4.png actual/grayscale-v.png $CMPR $SCALE -filter gaussian -gsf v.4,.1,.4 -grayscale
+$IW srcimg/4x4.png actual/grayscale-v.png $CMPR $SCALE -blur 1 -gsf v.4,.1,.4 -grayscale -nowarn
$IW srcimg/4x4.png actual/offset.png $DCMPR $SCALE -filter mix -offsetred .333 -offsetgreen -0.2 -offsetblue -1.5 -edge r
$IW srcimg/rgb8a.png actual/offsetv.png $DCMPR $SCALE -filter mix -offsetvred .333 -offsetvgreen -0.2 -offsetvblue -1.5 -edge r -nowarn

0 comments on commit 09c4f6f

Please sign in to comment.