~ubuntu-branches/ubuntu/oneiric/imagemagick/oneiric-updates

« back to all changes in this revision

Viewing changes to wand/identify.c

  • Committer: Bazaar Package Importer
  • Author(s): Nelson A. de Oliveira
  • Date: 2010-06-20 19:59:55 UTC
  • mfrom: (6.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100620195955-n3eq0yenhycw888i
Tags: 7:6.6.2.6-1
* New upstream release;
* Change Recommends on ufraw to ufraw-batch (Closes: #579775);
* Fix FTBFS when using dash to run the configure script, by setting
  CONFIG_SHELL=/bin/bash (Closes: #582073, #583024). Thank you, Niko Tyni!

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
%                            September 1994                                   %
18
18
%                                                                             %
19
19
%                                                                             %
20
 
%  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
 
20
%  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
21
21
%  dedicated to making software imaging solutions freely available.           %
22
22
%                                                                             %
23
23
%  You may not use this file except in compliance with the License.  You may  %
104
104
      "-version             print version information",
105
105
      (char *) NULL
106
106
    },
 
107
    *operators[]=
 
108
    {
 
109
      "-negate              replace every pixel with its complementary color ",
 
110
      (char *) NULL
 
111
    },
107
112
    *settings[]=
108
113
    {
109
114
      "-alpha option        on, activate, off, deactivate, set, opaque, copy",
119
124
      "-density geometry    horizontal and vertical density of the image",
120
125
      "-depth value         image depth",
121
126
      "-extract geometry    extract area from image",
 
127
      "-features distance   display image features (e.g. contrast, correlation)",
122
128
      "-format \"string\"     output formatted image characteristics",
123
129
      "-fuzz distance       colors within this distance are considered equal",
124
 
      "-gamma value         level of gamma correction",
 
130
      "-gamma value         of gamma correction",
125
131
      "-interlace type      type of image interlacing scheme",
126
132
      "-interpolate method  pixel color interpolation method",
127
133
      "-limit type value    pixel cache resource limit",
136
142
      "-set attribute value set an image attribute",
137
143
      "-size geometry       width and height of image",
138
144
      "-strip               strip image of all profiles and comments",
 
145
      "-unique              display the number of unique colors in the image",
139
146
      "-units type          the units of image resolution",
140
147
      "-verbose             print detailed information about the image",
141
148
      "-virtual-pixel method",
143
150
      (char *) NULL
144
151
    };
145
152
 
146
 
  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
 
153
  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
147
154
  (void) printf("Copyright: %s\n",GetMagickCopyright());
148
155
  (void) printf("Features: %s\n\n",GetMagickFeatures());
149
156
  (void) printf("Usage: %s [options ...] file [ [options ...] "
151
158
  (void) printf("\nImage Settings:\n");
152
159
  for (p=settings; *p != (char *) NULL; p++)
153
160
    (void) printf("  %s\n",*p);
 
161
  (void) printf("\nImage Operators:\n");
 
162
  for (p=operators; *p != (char *) NULL; p++)
 
163
    (void) printf("  %s\n",*p);
154
164
  (void) printf("\nMiscellaneous Options:\n");
155
165
  for (p=miscellaneous; *p != (char *) NULL; p++)
156
166
    (void) printf("  %s\n",*p);
172
182
#define DestroyIdentify() \
173
183
{ \
174
184
  DestroyImageStack(); \
175
 
  for (i=0; i < (long) argc; i++) \
 
185
  for (i=0; i < (ssize_t) argc; i++) \
176
186
    argv[i]=DestroyString(argv[i]); \
177
187
  argv=(char **) RelinquishMagickMemory(argv); \
178
188
}
201
211
  ImageStack
202
212
    image_stack[MaxImageStackDepth+1];
203
213
 
204
 
  long
 
214
  ssize_t
205
215
    j,
206
216
    k;
207
217
 
212
222
  MagickStatusType
213
223
    status;
214
224
 
215
 
  register long
 
225
  register ssize_t
216
226
    i;
217
227
 
218
 
  unsigned long
 
228
  size_t
219
229
    count;
220
230
 
221
231
  /*
233
243
          (LocaleCompare("-version",option+1) == 0))
234
244
        {
235
245
          (void) fprintf(stdout,"Version: %s\n",
236
 
            GetMagickVersion((unsigned long *) NULL));
 
246
            GetMagickVersion((size_t *) NULL));
237
247
          (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
238
248
          (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
239
249
          return(MagickFalse);
240
250
        }
241
251
    }
242
252
  if (argc < 2)
243
 
    {
244
 
      (void) IdentifyUsage();
245
 
      return(MagickTrue);
246
 
    }
 
253
    return(IdentifyUsage());
247
254
  count=0;
248
255
  format=NULL;
249
256
  j=1;
261
268
    ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
262
269
      GetExceptionMessage(errno));
263
270
  image_info->ping=MagickTrue;
264
 
  for (i=1; i < (long) argc; i++)
 
271
  for (i=1; i < (ssize_t) argc; i++)
265
272
  {
266
273
    option=argv[i];
267
274
    if (LocaleCompare(option,"(") == 0)
299
306
        identify_info=CloneImageInfo(image_info);
300
307
        identify_info->verbose=MagickFalse;
301
308
        filename=argv[i];
302
 
        if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
 
309
        if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
303
310
          filename=argv[++i];
304
311
        (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
305
312
        if (identify_info->ping != MagickFalse)
347
354
      {
348
355
        if (LocaleCompare("alpha",option+1) == 0)
349
356
          {
350
 
            long
 
357
            ssize_t
351
358
              type;
352
359
 
353
360
            if (*option == '+')
354
361
              break;
355
362
            i++;
356
 
            if (i == (long) argc)
 
363
            if (i == (ssize_t) argc)
357
364
              ThrowIdentifyException(OptionError,"MissingArgument",option);
358
365
            type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
359
366
            if (type < 0)
368
375
            if (*option == '+')
369
376
              break;
370
377
            i++;
371
 
            if (i == (long) (argc-1))
 
378
            if (i == (ssize_t) (argc-1))
372
379
              ThrowIdentifyException(OptionError,"MissingArgument",option);
373
380
            break;
374
381
          }
381
388
            if (*option == '+')
382
389
              break;
383
390
            i++;
384
 
            if (i == (long) argc)
 
391
            if (i == (ssize_t) argc)
385
392
              ThrowIdentifyException(OptionError,"MissingArgument",option);
386
393
            if (IsGeometry(argv[i]) == MagickFalse)
387
394
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
389
396
          }
390
397
        if (LocaleCompare("channel",option+1) == 0)
391
398
          {
392
 
            long
 
399
            ssize_t
393
400
              channel;
394
401
 
395
402
            if (*option == '+')
396
403
              break;
397
404
            i++;
398
 
            if (i == (long) (argc-1))
 
405
            if (i == (ssize_t) (argc-1))
399
406
              ThrowIdentifyException(OptionError,"MissingArgument",option);
400
407
            channel=ParseChannelOption(argv[i]);
401
408
            if (channel < 0)
405
412
          }
406
413
        if (LocaleCompare("colorspace",option+1) == 0)
407
414
          {
408
 
            long
 
415
            ssize_t
409
416
              colorspace;
410
417
 
411
418
            if (*option == '+')
412
419
              break;
413
420
            i++;
414
 
            if (i == (long) (argc-1))
 
421
            if (i == (ssize_t) (argc-1))
415
422
              ThrowIdentifyException(OptionError,"MissingArgument",option);
416
423
            colorspace=ParseMagickOption(MagickColorspaceOptions,
417
424
              MagickFalse,argv[i]);
425
432
            if (*option == '+')
426
433
              break;
427
434
            i++;
428
 
            if (i == (long) (argc-1))
 
435
            if (i == (ssize_t) (argc-1))
429
436
              ThrowIdentifyException(OptionError,"MissingArgument",option);
430
437
            if (IsGeometry(argv[i]) == MagickFalse)
431
438
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
440
447
      {
441
448
        if (LocaleCompare("debug",option+1) == 0)
442
449
          {
443
 
            long
 
450
            ssize_t
444
451
              event;
445
452
 
446
453
            if (*option == '+')
447
454
              break;
448
455
            i++;
449
 
            if (i == (long) argc)
 
456
            if (i == (ssize_t) argc)
450
457
              ThrowIdentifyException(OptionError,"MissingArgument",option);
451
458
            event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
452
459
            if (event < 0)
458
465
        if (LocaleCompare("define",option+1) == 0)
459
466
          {
460
467
            i++;
461
 
            if (i == (long) argc)
 
468
            if (i == (ssize_t) argc)
462
469
              ThrowIdentifyException(OptionError,"MissingArgument",option);
463
470
            if (*option == '+')
464
471
              {
477
484
            if (*option == '+')
478
485
              break;
479
486
            i++;
480
 
            if (i == (long) argc)
 
487
            if (i == (ssize_t) argc)
481
488
              ThrowIdentifyException(OptionError,"MissingArgument",option);
482
489
            if (IsGeometry(argv[i]) == MagickFalse)
483
490
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
488
495
            if (*option == '+')
489
496
              break;
490
497
            i++;
491
 
            if (i == (long) argc)
 
498
            if (i == (ssize_t) argc)
492
499
              ThrowIdentifyException(OptionError,"MissingArgument",option);
493
500
            if (IsGeometry(argv[i]) == MagickFalse)
494
501
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
499
506
            if (*option == '+')
500
507
              break;
501
508
            i++;
502
 
            if (i == (long) (argc-1))
 
509
            if (i == (ssize_t) (argc-1))
503
510
              ThrowIdentifyException(OptionError,"MissingArgument",option);
504
511
            if (IsGeometry(argv[i]) == MagickFalse)
505
512
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
509
516
      }
510
517
      case 'f':
511
518
      {
 
519
        if (LocaleCompare("features",option+1) == 0)
 
520
          {
 
521
            if (*option == '+')
 
522
              break;
 
523
            i++;
 
524
            if (i == (ssize_t) (argc-1))
 
525
              ThrowIdentifyException(OptionError,"MissingArgument",option);
 
526
            if (IsGeometry(argv[i]) == MagickFalse)
 
527
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
 
528
            break;
 
529
          }
512
530
        if (LocaleCompare("format",option+1) == 0)
513
531
          {
514
532
            format=(char *) NULL;
515
533
            if (*option == '+')
516
534
              break;
517
535
            i++;
518
 
            if (i == (long) argc)
 
536
            if (i == (ssize_t) argc)
519
537
              ThrowIdentifyException(OptionError,"MissingArgument",option);
520
538
            format=argv[i];
521
539
            break;
525
543
            if (*option == '+')
526
544
              break;
527
545
            i++;
528
 
            if (i == (long) (argc-1))
 
546
            if (i == (ssize_t) (argc-1))
529
547
              ThrowIdentifyException(OptionError,"MissingArgument",option);
530
548
            if (IsGeometry(argv[i]) == MagickFalse)
531
549
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
538
556
        if (LocaleCompare("gamma",option+1) == 0)
539
557
          {
540
558
            i++;
541
 
            if (i == (long) (argc-1))
 
559
            if (i == (ssize_t) (argc-1))
542
560
              ThrowIdentifyException(OptionError,"MissingArgument",option);
543
561
            if (IsGeometry(argv[i]) == MagickFalse)
544
562
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
557
575
      {
558
576
        if (LocaleCompare("interlace",option+1) == 0)
559
577
          {
560
 
            long
 
578
            ssize_t
561
579
              interlace;
562
580
 
563
581
            if (*option == '+')
564
582
              break;
565
583
            i++;
566
 
            if (i == (long) argc)
 
584
            if (i == (ssize_t) argc)
567
585
              ThrowIdentifyException(OptionError,"MissingArgument",option);
568
586
            interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
569
587
              argv[i]);
574
592
          }
575
593
        if (LocaleCompare("interpolate",option+1) == 0)
576
594
          {
577
 
            long
 
595
            ssize_t
578
596
              interpolate;
579
597
 
580
598
            if (*option == '+')
581
599
              break;
582
600
            i++;
583
 
            if (i == (long) argc)
 
601
            if (i == (ssize_t) argc)
584
602
              ThrowIdentifyException(OptionError,"MissingArgument",option);
585
603
            interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
586
604
              argv[i]);
601
619
            double
602
620
              value;
603
621
 
604
 
            long
 
622
            ssize_t
605
623
              resource;
606
624
 
607
625
            if (*option == '+')
608
626
              break;
609
627
            i++;
610
 
            if (i == (long) argc)
 
628
            if (i == (ssize_t) argc)
611
629
              ThrowIdentifyException(OptionError,"MissingArgument",option);
612
630
            resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
613
631
              argv[i]);
615
633
              ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
616
634
                argv[i]);
617
635
            i++;
618
 
            if (i == (long) argc)
 
636
            if (i == (ssize_t) argc)
619
637
              ThrowIdentifyException(OptionError,"MissingArgument",option);
620
638
            value=strtod(argv[i],&p);
621
639
            if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
624
642
          }
625
643
        if (LocaleCompare("list",option+1) == 0)
626
644
          {
627
 
            long
 
645
            ssize_t
628
646
              list;
629
647
 
630
648
            if (*option == '+')
631
649
              break;
632
650
            i++;
633
 
            if (i == (long) argc)
 
651
            if (i == (ssize_t) argc)
634
652
              ThrowIdentifyException(OptionError,"MissingArgument",option);
635
653
            list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
636
654
            if (list < 0)
637
655
              ThrowIdentifyException(OptionError,"UnrecognizedListType",
638
656
                argv[i]);
639
 
            (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
 
657
            status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
640
658
              argv+j,exception);
641
659
            DestroyIdentify();
642
 
            return(MagickTrue);
 
660
            return(status != 0 ? MagickFalse : MagickTrue);
643
661
          }
644
662
        if (LocaleCompare("log",option+1) == 0)
645
663
          {
646
664
            if (*option == '+')
647
665
              break;
648
666
            i++;
649
 
            if ((i == (long) argc) ||
 
667
            if ((i == (ssize_t) argc) ||
650
668
                (strchr(argv[i],'%') == (char *) NULL))
651
669
              ThrowIdentifyException(OptionError,"MissingArgument",option);
652
670
            break;
661
679
          break;
662
680
        ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
663
681
      }
 
682
      case 'n':
 
683
      {
 
684
        if (LocaleCompare("negate",option+1) == 0)
 
685
          break;
 
686
        ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
 
687
      }
664
688
      case 'p':
665
689
      {
666
690
        if (LocaleCompare("ping",option+1) == 0)
691
715
            if (*option == '+')
692
716
              break;
693
717
            i++;
694
 
            if (i == (long) argc)
 
718
            if (i == (ssize_t) argc)
695
719
              ThrowIdentifyException(OptionError,"MissingArgument",option);
696
720
            if (IsGeometry(argv[i]) == MagickFalse)
697
721
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
702
726
            if (*option == '+')
703
727
              break;
704
728
            i++;
705
 
            if (i == (long) (argc-1))
 
729
            if (i == (ssize_t) (argc-1))
706
730
              ThrowIdentifyException(OptionError,"MissingArgument",option);
707
731
            if (IsGeometry(argv[i]) == MagickFalse)
708
732
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
711
735
        if (LocaleCompare("set",option+1) == 0)
712
736
          {
713
737
            i++;
714
 
            if (i == (long) argc)
 
738
            if (i == (ssize_t) argc)
715
739
              ThrowIdentifyException(OptionError,"MissingArgument",option);
716
740
            if (*option == '+')
717
741
              break;
718
742
            i++;
719
 
            if (i == (long) argc)
 
743
            if (i == (ssize_t) argc)
720
744
              ThrowIdentifyException(OptionError,"MissingArgument",option);
721
745
            break;
722
746
          }
725
749
            if (*option == '+')
726
750
              break;
727
751
            i++;
728
 
            if (i == (long) argc)
 
752
            if (i == (ssize_t) argc)
729
753
              ThrowIdentifyException(OptionError,"MissingArgument",option);
730
754
            if (IsGeometry(argv[i]) == MagickFalse)
731
755
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
738
762
            if (*option == '+')
739
763
              break;
740
764
            i++;
741
 
            if (i == (long) argc)
 
765
            if (i == (ssize_t) argc)
742
766
              ThrowIdentifyException(OptionError,"MissingArgument",option);
743
767
            if (IsGeometry(argv[i]) == MagickFalse)
744
768
              ThrowIdentifyInvalidArgumentException(option,argv[i]);
748
772
      }
749
773
      case 'u':
750
774
      {
 
775
        if (LocaleCompare("unique",option+1) == 0)
 
776
          break;
751
777
        if (LocaleCompare("units",option+1) == 0)
752
778
          {
753
 
            long
 
779
            ssize_t
754
780
              units;
755
781
 
756
782
            if (*option == '+')
757
783
              break;
758
784
            i++;
759
 
            if (i == (long) (argc-1))
 
785
            if (i == (ssize_t) (argc-1))
760
786
              ThrowIdentifyException(OptionError,"MissingArgument",option);
761
787
            units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
762
788
              argv[i]);
773
799
          break;
774
800
        if (LocaleCompare("virtual-pixel",option+1) == 0)
775
801
          {
776
 
            long
 
802
            ssize_t
777
803
              method;
778
804
 
779
805
            if (*option == '+')
780
806
              break;
781
807
            i++;
782
 
            if (i == (long) (argc-1))
 
808
            if (i == (ssize_t) (argc-1))
783
809
              ThrowIdentifyException(OptionError,"MissingArgument",option);
784
810
            method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
785
811
              argv[i]);
802
828
  }
803
829
  if (k != 0)
804
830
    ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
805
 
  if (i != argc)
 
831
  if (i != (ssize_t) argc)
806
832
    ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
807
833
  DestroyIdentify();
808
834
  return(status != 0 ? MagickTrue : MagickFalse);