Skip to content

Commit ab3a50c

Browse files
author
anthony
committed
1 parent c763241 commit ab3a50c

File tree

1 file changed

+59
-100
lines changed

1 file changed

+59
-100
lines changed

MagickWand/operation.c

Lines changed: 59 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,15 +1416,12 @@ WandExport MagickBooleanType ApplySettingsOption(ImageInfo *image_info,
14161416
}
14171417
if (LocaleCompare("type",option) == 0)
14181418
{
1419-
if (*argv[0] == '+')
1420-
{
1421-
image_info->type=UndefinedType;
1422-
(void) SetImageOption(image_info,option,"undefined");
1423-
break;
1424-
}
1425-
image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
1426-
MagickFalse,argv[1]);
1427-
(void) SetImageOption(image_info,option,argv[1]);
1419+
(void) SetImageOption(image_info,option,
1420+
IfSetOption ? argv[1] : (char) NULL);
1421+
image_info->type=UndefinedType;
1422+
if (IfSetOption)
1423+
image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions,
1424+
MagickFalse,argv[1]);
14281425
break;
14291426
}
14301427
break;
@@ -1433,25 +1430,23 @@ WandExport MagickBooleanType ApplySettingsOption(ImageInfo *image_info,
14331430
{
14341431
if (LocaleCompare("undercolor",option) == 0)
14351432
{
1436-
if (*argv[0] == '+')
1437-
{
1438-
(void) DeleteImageOption(image_info,option);
1439-
break;
1440-
}
1441-
(void) SetImageOption(image_info,option,argv[1]);
1433+
(void) SetImageOption(image_info,option,
1434+
IfSetOption ? argv[1] : (char) NULL);
1435+
(void) QueryColorCompliance(argv[1],AllCompliance,
1436+
draw_info->undercolor,exception);
14421437
break;
14431438
}
14441439
if (LocaleCompare("units",option) == 0)
14451440
{
1446-
if (*argv[0] == '+')
1447-
{
1448-
image_info->units=UndefinedResolution;
1449-
(void) SetImageOption(image_info,option,"undefined");
1450-
break;
1451-
}
1452-
image_info->units=(ResolutionType) ParseCommandOption(
1453-
MagickResolutionOptions,MagickFalse,argv[1]);
1454-
(void) SetImageOption(image_info,option,argv[1]);
1441+
/* Set in images via SyncImageSettings() */
1442+
/* Should this effect draw_info X and Y resolution? */
1443+
/* FUTURE: this probably should be part of the density setting */
1444+
(void) SetImageOption(image_info,option,
1445+
IfSetOption ? argv[1] : (char) NULL);
1446+
image_info->units=UndefinedResolution;
1447+
if (IfSetOption)
1448+
image_info->units=(ResolutionType) ParseCommandOption(
1449+
MagickResolutionOptions,MagickFalse,argv[1]);
14551450
break;
14561451
}
14571452
break;
@@ -1460,43 +1455,57 @@ WandExport MagickBooleanType ApplySettingsOption(ImageInfo *image_info,
14601455
{
14611456
if (LocaleCompare("verbose",option) == 0)
14621457
{
1463-
if (*argv[0] == '+')
1464-
{
1465-
image_info->verbose=MagickFalse;
1466-
break;
1467-
}
1468-
image_info->verbose=MagickTrue;
1469-
image_info->ping=MagickFalse;
1458+
/* FUTURE: Also an image artifact, set in Simple Operators.
1459+
But artifact is only used in verbose output.
1460+
*/
1461+
image_info->verbose= IfSetOption ? MagickTrue : MagickFalse;
1462+
image_info->ping=MagickFalse; /* verbose can't be a ping */
14701463
break;
14711464
}
14721465
if (LocaleCompare("view",option) == 0)
14731466
{
1474-
if (*argv[0] == '+')
1475-
{
1476-
if (image_info->view != (char *) NULL)
1477-
image_info->view=DestroyString(image_info->view);
1478-
break;
1479-
}
1480-
(void) CloneString(&image_info->view,argv[1]);
1467+
/* FUTURE: Convert from image_info to Option
1468+
Only used by coder FPX
1469+
*/
1470+
(void) CloneString(&image_info->view,
1471+
IfSetOption ? argv[1] : (char) NULL);
14811472
break;
14821473
}
14831474
if (LocaleCompare("virtual-pixel",option) == 0)
14841475
{
1485-
if (*argv[0] == '+')
1486-
{
1487-
image_info->virtual_pixel_method=UndefinedVirtualPixelMethod;
1488-
(void) SetImageOption(image_info,option,"undefined");
1489-
break;
1490-
}
1476+
/* Also used as a 'image' option deep in image structure */
1477+
const char
1478+
*value = IfSetOption ? argv[1] : "undefined";
1479+
1480+
(void) SetImageOption(image_info,option,value);
14911481
image_info->virtual_pixel_method=(VirtualPixelMethod)
1492-
ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,argv[1]);
1493-
(void) SetImageOption(image_info,option,argv[1]);
1482+
ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,value);
14941483
break;
14951484
}
14961485
break;
14971486
}
14981487
case 'w':
14991488
{
1489+
if (LocaleCompare("weight",argv[0]+1) == 0)
1490+
{
1491+
/* FUTURE: relative weights not sensical due to first assignment!
1492+
Also just what is actually using font 'weight' ???
1493+
*/
1494+
draw_info->weight=StringToUnsignedLong(argv[1]);
1495+
if (LocaleCompare(argv[1],"all") == 0)
1496+
draw_info->weight=0;
1497+
if (LocaleCompare(argv[1],"bold") == 0)
1498+
draw_info->weight=700;
1499+
if (LocaleCompare(argv[1],"bolder") == 0)
1500+
if (draw_info->weight <= 800)
1501+
draw_info->weight+=100;
1502+
if (LocaleCompare(argv[1],"lighter") == 0)
1503+
if (draw_info->weight >= 100)
1504+
draw_info->weight-=100;
1505+
if (LocaleCompare(argv[1],"normal") == 0)
1506+
draw_info->weight=400;
1507+
break;
1508+
}
15001509
if (LocaleCompare("white-point",option) == 0)
15011510
{
15021511
if (*argv[0] == '+')
@@ -3527,29 +3536,15 @@ MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
35273536
}
35283537
if (LocaleCompare("type",argv[0]+1) == 0)
35293538
{
3530-
ImageType
3531-
type;
3532-
3539+
/* Note that "type" setting should have already been defined */
35333540
(void) SyncImageSettings(image_info,*image,exception);
3534-
if (*argv[0] == '+')
3535-
type=UndefinedType;
3536-
else
3537-
type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse,
3538-
argv[1]);
3539-
(*image)->type=UndefinedType;
35403541
(void) SetImageType(*image,type,exception);
35413542
break;
35423543
}
35433544
break;
35443545
}
35453546
case 'u':
35463547
{
3547-
if (LocaleCompare("undercolor",argv[0]+1) == 0)
3548-
{
3549-
(void) QueryColorCompliance(argv[1],AllCompliance,&draw_info->undercolor,
3550-
exception);
3551-
break;
3552-
}
35533548
if (LocaleCompare("unique",argv[0]+1) == 0)
35543549
{
35553550
if (*argv[0] == '+')
@@ -3563,18 +3558,12 @@ MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
35633558
}
35643559
if (LocaleCompare("unique-colors",argv[0]+1) == 0)
35653560
{
3566-
/*
3567-
Unique image colors.
3568-
*/
35693561
(void) SyncImageSettings(image_info,*image,exception);
35703562
new_image=UniqueImageColors(*image,exception);
35713563
break;
35723564
}
35733565
if (LocaleCompare("unsharp",argv[0]+1) == 0)
35743566
{
3575-
/*
3576-
Unsharp mask image.
3577-
*/
35783567
(void) SyncImageSettings(image_info,*image,exception);
35793568
flags=ParseGeometry(argv[1],&geometry_info);
35803569
if ((flags & SigmaValue) == 0)
@@ -3594,7 +3583,7 @@ MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
35943583
if (LocaleCompare("verbose",argv[0]+1) == 0)
35953584
{
35963585
(void) SetImageArtifact(*image,argv[0]+1,
3597-
*argv[0] == '+' ? "false" : "true");
3586+
*argv[0] == '+' ? "false" : "true");
35983587
break;
35993588
}
36003589
if (LocaleCompare("vignette",argv[0]+1) == 0)
@@ -3617,15 +3606,8 @@ MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
36173606
}
36183607
if (LocaleCompare("virtual-pixel",argv[0]+1) == 0)
36193608
{
3620-
if (*argv[0] == '+')
3621-
{
3622-
(void) SetImageVirtualPixelMethod(*image,
3623-
UndefinedVirtualPixelMethod);
3624-
break;
3625-
}
3626-
(void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
3627-
ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
3628-
argv[1]));
3609+
/* setting already defined in image_info structure */
3610+
SetImageVirtualPixelMethod(*image, image_info->virtual_pixel_method);
36293611
break;
36303612
}
36313613
break;
@@ -3634,9 +3616,6 @@ MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
36343616
{
36353617
if (LocaleCompare("wave",argv[0]+1) == 0)
36363618
{
3637-
/*
3638-
Wave image.
3639-
*/
36403619
(void) SyncImageSettings(image_info,*image,exception);
36413620
flags=ParseGeometry(argv[1],&geometry_info);
36423621
if ((flags & SigmaValue) == 0)
@@ -3645,28 +3624,8 @@ MagickExport MagickBooleanType ApplyImageOperator(MagickWand *wand,
36453624
geometry_info.sigma,interpolate_method,exception);
36463625
break;
36473626
}
3648-
if (LocaleCompare("weight",argv[0]+1) == 0)
3649-
{
3650-
draw_info->weight=StringToUnsignedLong(argv[1]);
3651-
if (LocaleCompare(argv[1],"all") == 0)
3652-
draw_info->weight=0;
3653-
if (LocaleCompare(argv[1],"bold") == 0)
3654-
draw_info->weight=700;
3655-
if (LocaleCompare(argv[1],"bolder") == 0)
3656-
if (draw_info->weight <= 800)
3657-
draw_info->weight+=100;
3658-
if (LocaleCompare(argv[1],"lighter") == 0)
3659-
if (draw_info->weight >= 100)
3660-
draw_info->weight-=100;
3661-
if (LocaleCompare(argv[1],"normal") == 0)
3662-
draw_info->weight=400;
3663-
break;
3664-
}
36653627
if (LocaleCompare("white-threshold",argv[0]+1) == 0)
36663628
{
3667-
/*
3668-
White threshold image.
3669-
*/
36703629
(void) SyncImageSettings(image_info,*image,exception);
36713630
(void) WhiteThresholdImage(*image,argv[1],exception);
36723631
break;

0 commit comments

Comments
 (0)