Class: Magick::Image::Info

Inherits:
Object
  • Object
show all
Defined in:
ext/RMagick/rmmain.cpp

Instance Method Summary collapse

Constructor Details

#initializeObject



2418
2419
2420
2421
2422
2423
2424
2425
2426
# File 'ext/RMagick/rminfo.cpp', line 2418

VALUE
Info_initialize(VALUE self)
{
    if (rb_block_given_p())
    {
        rb_yield(self);
    }
    return self;
}

Instance Method Details

#[](*args) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'ext/RMagick/rminfo.cpp', line 260

VALUE
Info_aref(int argc, VALUE *argv, VALUE self)
{
    Info *info;
    char *format_p, *key_p;
    size_t format_l, key_l;
    const char *value;
    char fkey[MaxTextExtent];

    switch (argc)
    {
        case 2:
            format_p = rm_str2cstr(&argv[0], &format_l);
            key_p = rm_str2cstr(&argv[1], &key_l);
            if (format_l > MAX_FORMAT_LEN || format_l + key_l > MaxTextExtent-1)
            {
                rb_raise(rb_eArgError, "can't reference %.60s:%.1024s - too long", format_p, key_p);
            }

            snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
            break;

        case 1:
            strlcpy(fkey, StringValueCStr(argv[0]), sizeof(fkey));
            break;

        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
            break;

    }

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    value = GetImageOption(info, fkey);
    if (!value)
    {
        return Qnil;
    }

    return rb_str_new2(value);
}

#[]=(*args) ⇒ Object



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'ext/RMagick/rminfo.cpp', line 322

VALUE
Info_aset(int argc, VALUE *argv, VALUE self)
{
    Info *info;
    VALUE value;
    char *format_p, *key_p, *value_p = NULL;
    size_t format_l, key_l;
    char ckey[MaxTextExtent];

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    switch (argc)
    {
        case 3:
            format_p = rm_str2cstr(&argv[0], &format_l);
            key_p = rm_str2cstr(&argv[1], &key_l);

            if (format_l > MAX_FORMAT_LEN || format_l+key_l > MaxTextExtent-1)
            {
                rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p);
            }

            snprintf(ckey, sizeof(ckey), "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);

            value = argv[2];
            break;

        case 2:
            strlcpy(ckey, StringValueCStr(argv[0]), sizeof(ckey));

            value = argv[1];
            break;

        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
            break;
    }

    if (NIL_P(value))
    {
        DeleteImageOption(info, ckey);
    }
    else
    {
        unsigned int okay;

        /* Allow any argument that supports to_s */
        value = rb_String(value);
        value_p = StringValueCStr(value);

        okay = SetImageOption(info, ckey, value_p);
        if (!okay)
        {
            rb_warn("`%s' not defined - SetImageOption failed.", ckey);
            return Qnil;
        }
    }

    RB_GC_GUARD(value);

    return self;
}

#antialiasBoolean

Get antialias value

Returns:

  • (Boolean)

    true if antialias is enabled



223
224
225
226
227
# File 'ext/RMagick/rminfo.cpp', line 223

VALUE
Info_antialias(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, antialias, boolean, &rm_info_data_type);
}

#antialias=(val) ⇒ Object



235
236
237
238
239
# File 'ext/RMagick/rminfo.cpp', line 235

VALUE
Info_antialias_eq(VALUE self, VALUE val)
{
    IMPLEMENT_TYPED_ATTR_WRITER(Info, antialias, boolean, &rm_info_data_type);
}

#attenuateObject



391
392
393
394
395
# File 'ext/RMagick/rminfo.cpp', line 391

VALUE
Info_attenuate(VALUE self)
{
    return get_dbl_option(self, "attenuate");
}

#attenuate=(value) ⇒ Object



404
405
406
407
408
# File 'ext/RMagick/rminfo.cpp', line 404

VALUE
Info_attenuate_eq(VALUE self, VALUE value)
{
    return set_dbl_option(self, "attenuate", value);
}

#authenticateObject



416
417
418
419
420
421
422
423
424
425
426
427
# File 'ext/RMagick/rminfo.cpp', line 416

VALUE
Info_authenticate(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
#if defined(IMAGEMAGICK_7)
    return C_str_to_R_str(GetImageOption(info, "authenticate"));
#else
    return C_str_to_R_str(info->authenticate);
#endif
}

#authenticate=(passwd_arg) ⇒ Object



436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'ext/RMagick/rminfo.cpp', line 436

VALUE
Info_authenticate_eq(VALUE self, VALUE passwd_arg)
{
    Info *info;
    char *passwd = NULL;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (!NIL_P(passwd_arg))
    {
        passwd = StringValueCStr(passwd_arg);
    }

#if defined(IMAGEMAGICK_7)
    if (passwd)
    {
        SetImageOption(info, "authenticate", passwd);
    }
    else
    {
        DeleteImageOption(info, "authenticate");
    }
#else
    if (info->authenticate)
    {
        magick_free(info->authenticate);
        info->authenticate = NULL;
    }
    if (passwd)
    {
        magick_clone_string(&info->authenticate, passwd);
    }
#endif

    return passwd_arg;
}

#background_colorObject



480
481
482
483
484
485
486
487
# File 'ext/RMagick/rminfo.cpp', line 480

VALUE
Info_background_color(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return rm_pixelcolor_to_color_name_info(info, &info->background_color);
}

#background_color=(bc_arg) ⇒ Object



496
497
498
499
500
501
502
503
504
505
# File 'ext/RMagick/rminfo.cpp', line 496

VALUE
Info_background_color_eq(VALUE self, VALUE bc_arg)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    Color_to_PixelColor(&info->background_color, bc_arg);

    return bc_arg;
}

#border_colorObject



513
514
515
516
517
518
519
520
# File 'ext/RMagick/rminfo.cpp', line 513

VALUE
Info_border_color(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return rm_pixelcolor_to_color_name_info(info, &info->border_color);
}

#border_color=(bc_arg) ⇒ Object



528
529
530
531
532
533
534
535
536
537
# File 'ext/RMagick/rminfo.cpp', line 528

VALUE
Info_border_color_eq(VALUE self, VALUE bc_arg)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    Color_to_PixelColor(&info->border_color, bc_arg);

    return bc_arg;
}

#captionObject



546
547
548
549
550
# File 'ext/RMagick/rminfo.cpp', line 546

VALUE
Info_caption(VALUE self)
{
    return get_option(self, "caption");
}

#caption=(caption) ⇒ Object



560
561
562
563
564
# File 'ext/RMagick/rminfo.cpp', line 560

VALUE
Info_caption_eq(VALUE self, VALUE caption)
{
    return set_option(self, "caption", caption);
}

#channel(*args) ⇒ Object



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
# File 'ext/RMagick/rminfo.cpp', line 578

VALUE
Info_channel(int argc, VALUE *argv, VALUE self)
{
    Info *info;
    ChannelType channels;

    channels = extract_channels(&argc, argv);

    // Ensure all arguments consumed.
    if (argc > 0)
    {
        raise_ChannelType_error(argv[argc-1]);
    }

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    info->channel = channels;
    return self;
}

#colorspaceObject



604
605
606
607
608
609
610
611
# File 'ext/RMagick/rminfo.cpp', line 604

VALUE
Info_colorspace(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return ColorspaceType_find(info->colorspace);
}

#colorspace=(colorspace) ⇒ Object



619
620
621
622
623
624
625
626
627
# File 'ext/RMagick/rminfo.cpp', line 619

VALUE
Info_colorspace_eq(VALUE self, VALUE colorspace)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    VALUE_TO_ENUM(colorspace, info->colorspace, ColorspaceType);
    return colorspace;
}

#commentObject



634
635
636
637
# File 'ext/RMagick/rminfo.cpp', line 634

VALUE Info_comment(VALUE self)
{
    return get_option(self, "Comment");
}

#comment=(string) ⇒ Object



645
646
647
648
# File 'ext/RMagick/rminfo.cpp', line 645

VALUE Info_comment_eq(VALUE self, VALUE string)
{
    return set_option(self, "Comment", string);
}

#compressionObject



655
656
657
658
659
660
661
662
# File 'ext/RMagick/rminfo.cpp', line 655

VALUE
Info_compression(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return CompressionType_find(info->compression);
}

#compression=(type) ⇒ Object



670
671
672
673
674
675
676
677
678
# File 'ext/RMagick/rminfo.cpp', line 670

VALUE
Info_compression_eq(VALUE self, VALUE type)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    VALUE_TO_ENUM(type, info->compression, CompressionType);
    return type;
}

#define(*args) ⇒ Object



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'ext/RMagick/rminfo.cpp', line 690

VALUE
Info_define(int argc, VALUE *argv, VALUE self)
{
    Info *info;
    char *format, *key;
    const char *value = "";
    size_t format_l, key_l;
    char ckey[100];
    unsigned int okay;
    VALUE fmt_arg;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    switch (argc)
    {
        case 3:
            /* Allow any argument that supports to_s */
            fmt_arg = rb_String(argv[2]);
            value = (const char *)StringValueCStr(fmt_arg);
        case 2:
            key = rm_str2cstr(&argv[1], &key_l);
            format = rm_str2cstr(&argv[0], &format_l);
            break;
        default:
            rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
    }

    if (2 + format_l + key_l > (long)sizeof(ckey))
    {
        rb_raise(rb_eArgError, "%.20s:%.20s not defined - format or key too long", format, key);
    }
    snprintf(ckey, sizeof(ckey), "%s:%s", format, key);

    DeleteImageOption(info, ckey);
    okay = SetImageOption(info, ckey, value);
    if (!okay)
    {
        rb_warn("%.20s=\"%.78s\" not defined - SetImageOption failed.", ckey, value);
        return Qnil;
    }

    RB_GC_GUARD(fmt_arg);

    return self;
}

#delayObject



741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'ext/RMagick/rminfo.cpp', line 741

VALUE
Info_delay(VALUE self)
{
    Info *info;
    const char *delay;
    char *p;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    delay = GetImageOption(info, "delay");
    if (delay)
    {
        long d;

        d = strtol(delay, &p, 10);
        if (*p != '\0')
        {
            rb_raise(rb_eRangeError, "failed to convert %s to Numeric", delay);
        }
        return LONG2NUM(d);
    }
    return Qnil;
}

#delay=(string) ⇒ Object



785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
# File 'ext/RMagick/rminfo.cpp', line 785

VALUE
Info_delay_eq(VALUE self, VALUE string)
{
    Info *info;
    int not_num;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(string))
    {
        DeleteImageOption(info, "delay");
    }
    else
    {
        char dstr[20];
        int delay;

        not_num = 0;
        rb_protect(arg_is_integer, string, &not_num);
        if (not_num)
        {
            rb_raise(rb_eTypeError, "failed to convert %s into Integer", rb_class2name(CLASS_OF(string)));
        }
        delay = NUM2INT(string);
        snprintf(dstr, sizeof(dstr), "%d", delay);
        SetImageOption(info, "delay", dstr);
    }
    return string;
}

#densityObject



820
821
822
823
824
# File 'ext/RMagick/rminfo.cpp', line 820

VALUE
Info_density(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, density, str, &rm_info_data_type);
}

#density=(density_arg) ⇒ Object



833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
# File 'ext/RMagick/rminfo.cpp', line 833

VALUE
Info_density_eq(VALUE self, VALUE density_arg)
{
    Info *info;
    VALUE density;
    char *dens;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(density_arg))
    {
        magick_free(info->density);
        info->density = NULL;
        return density_arg;
    }

    density = rb_String(density_arg);
    dens = StringValueCStr(density);
    if (!IsGeometry(dens))
    {
        rb_raise(rb_eArgError, "invalid density geometry: %s", dens);
    }

    magick_clone_string(&info->density, dens);

    RB_GC_GUARD(density);

    return density_arg;
}

#depthObject



868
869
870
871
872
# File 'ext/RMagick/rminfo.cpp', line 868

VALUE
Info_depth(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, depth, int, &rm_info_data_type);
}

#depth=(depth) ⇒ Object



880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
# File 'ext/RMagick/rminfo.cpp', line 880

VALUE
Info_depth_eq(VALUE self, VALUE depth)
{
    Info *info;
    unsigned long d;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    d = NUM2ULONG(depth);
    switch (d)
    {
        case 8:                     // always okay
#if MAGICKCORE_QUANTUM_DEPTH == 16 || MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64
        case 16:
#if MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64
        case 32:
#if MAGICKCORE_QUANTUM_DEPTH == 64
        case 64:
#endif
#endif
#endif
            break;
        default:
            rb_raise(rb_eArgError, "invalid depth (%lu)", d);
            break;
    }

    info->depth = d;
    return depth;
}

#disposeObject



963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
# File 'ext/RMagick/rminfo.cpp', line 963

VALUE
Info_dispose(VALUE self)
{
    Info *info;
    ID dispose_id;
    const char *dispose;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    dispose_id = rb_intern("UndefinedDispose");

    // Map the dispose option string to a DisposeType enumerator.
    dispose = GetImageOption(info, "dispose");
    if (dispose)
    {
        for (int x = 0; x < N_DISPOSE_OPTIONS; x++)
        {
            if (strcmp(dispose, Dispose_Option[x].string) == 0)
            {
                dispose_id = rb_intern(Dispose_Option[x].enum_name);
                break;
            }
        }
    }

    return rb_const_get(Module_Magick, dispose_id);
}

#dispose=(disp) ⇒ Object



997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
# File 'ext/RMagick/rminfo.cpp', line 997

VALUE
Info_dispose_eq(VALUE self, VALUE disp)
{
    Info *info;
    DisposeType dispose;
    const char *option;
    int x;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(disp))
    {
        DeleteImageOption(info, "dispose");
        return disp;
    }

    VALUE_TO_ENUM(disp, dispose, DisposeType);
    option = "Undefined";

    for (x = 0; x < N_DISPOSE_OPTIONS; x++)
    {
        if (dispose == Dispose_Option[x].enumerator)
        {
            option = Dispose_Option[x].string;
            break;
        }
    }

    SetImageOption(info, "dispose", option);
    return disp;
}

#ditherObject



1034
1035
1036
1037
1038
# File 'ext/RMagick/rminfo.cpp', line 1034

VALUE
Info_dither(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, dither, boolean, &rm_info_data_type);
}

#dither=(val) ⇒ Object



1046
1047
1048
1049
1050
# File 'ext/RMagick/rminfo.cpp', line 1046

VALUE
Info_dither_eq(VALUE self, VALUE val)
{
    IMPLEMENT_TYPED_ATTR_WRITER(Info, dither, boolean, &rm_info_data_type);
}

#endianObject



1058
1059
1060
1061
1062
1063
1064
1065
# File 'ext/RMagick/rminfo.cpp', line 1058

VALUE
Info_endian(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return EndianType_find(info->endian);
}

#endian=(endian) ⇒ Object



1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
# File 'ext/RMagick/rminfo.cpp', line 1074

VALUE
Info_endian_eq(VALUE self, VALUE endian)
{
    Info *info;
    EndianType type = UndefinedEndian;

    if (endian != Qnil)
    {
        VALUE_TO_ENUM(endian, type, EndianType);
    }

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    info->endian = type;
    return endian;
}

#extractObject



1097
1098
1099
1100
1101
# File 'ext/RMagick/rminfo.cpp', line 1097

VALUE
Info_extract(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, extract, str, &rm_info_data_type);
}

#extract=(extract_arg) ⇒ Object



1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
# File 'ext/RMagick/rminfo.cpp', line 1110

VALUE
Info_extract_eq(VALUE self, VALUE extract_arg)
{
    Info *info;
    char *extr;
    VALUE extract;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(extract_arg))
    {
        magick_free(info->extract);
        info->extract = NULL;
        return extract_arg;
    }

    extract = rb_String(extract_arg);
    extr = StringValueCStr(extract);
    if (!IsGeometry(extr))
    {
        rb_raise(rb_eArgError, "invalid extract geometry: %s", extr);
    }

    magick_clone_string(&info->extract, extr);

    RB_GC_GUARD(extract);

    return extract_arg;
}

#filenameObject



1148
1149
1150
1151
1152
1153
1154
1155
# File 'ext/RMagick/rminfo.cpp', line 1148

VALUE
Info_filename(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return rb_str_new2(info->filename);
}

#filename=(filename) ⇒ Object



1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
# File 'ext/RMagick/rminfo.cpp', line 1165

VALUE
Info_filename_eq(VALUE self, VALUE filename)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    // Allow "nil" - remove current filename
    if (NIL_P(filename) || StringValueCStr(filename) == NULL)
    {
        info->filename[0] = '\0';
    }
    else
    {
        char *fname;

        // Otherwise copy in filename
        fname = StringValueCStr(filename);
        strlcpy(info->filename, fname, sizeof(info->filename));
    }
    return filename;
}

#fillObject



1194
1195
1196
1197
1198
# File 'ext/RMagick/rminfo.cpp', line 1194

VALUE
Info_fill(VALUE self)
{
    return get_option(self, "fill");
}

#fill=(color) ⇒ Object



1206
1207
1208
1209
1210
# File 'ext/RMagick/rminfo.cpp', line 1206

VALUE
Info_fill_eq(VALUE self, VALUE color)
{
    return set_color_option(self, "fill", color);
}

#fontObject



1218
1219
1220
1221
1222
# File 'ext/RMagick/rminfo.cpp', line 1218

VALUE
Info_font(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, font, str, &rm_info_data_type);
}

#font=(font_arg) ⇒ Object



1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'ext/RMagick/rminfo.cpp', line 1230

VALUE
Info_font_eq(VALUE self, VALUE font_arg)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    if (NIL_P(font_arg) || StringValueCStr(font_arg) == NULL)
    {
        magick_free(info->font);
        info->font = NULL;
    }
    else
    {
        char *font;

        font = StringValueCStr(font_arg);
        magick_clone_string(&info->font, font);
    }
    return font_arg;
}

#formatObject



1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
# File 'ext/RMagick/rminfo.cpp', line 1256

VALUE Info_format(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    if (*info->magick)
    {
        const MagickInfo *magick_info;
        ExceptionInfo *exception;

        exception = AcquireExceptionInfo();
        magick_info = GetMagickInfo(info->magick, exception);
        DestroyExceptionInfo(exception);

        return magick_info ? rb_str_new2(magick_info->name) : Qnil;
    }

    return Qnil;
}

#format=(magick) ⇒ Object



1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
# File 'ext/RMagick/rminfo.cpp', line 1282

VALUE
Info_format_eq(VALUE self, VALUE magick)
{
    Info *info;
    const MagickInfo *m;
    char *mgk;
    ExceptionInfo *exception;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    mgk = StringValueCStr(magick);

    exception = AcquireExceptionInfo();
    m = GetMagickInfo(mgk, exception);
    CHECK_EXCEPTION();
    DestroyExceptionInfo(exception);

    if (!m)
    {
        rb_raise(rb_eArgError, "unknown format: %s", mgk);
    }

    strlcpy(info->magick, m->name, sizeof(info->magick));
    return magick;
}

#freezeObject



313
314
315
316
317
# File 'ext/RMagick/rmutil.cpp', line 313

VALUE
rm_no_freeze(VALUE obj)
{
    rb_raise(rb_eTypeError, "can't freeze %s", rb_class2name(CLASS_OF(obj)));
}

#fuzzObject



1314
1315
1316
1317
1318
# File 'ext/RMagick/rminfo.cpp', line 1314

VALUE
Info_fuzz(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, fuzz, dbl, &rm_info_data_type);
}

#fuzz=(fuzz) ⇒ Object



1328
1329
1330
1331
1332
1333
1334
1335
1336
# File 'ext/RMagick/rminfo.cpp', line 1328

VALUE
Info_fuzz_eq(VALUE self, VALUE fuzz)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    info->fuzz = rm_fuzz_to_dbl(fuzz);
    return fuzz;
}

#gravityObject



1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
# File 'ext/RMagick/rminfo.cpp', line 1394

VALUE Info_gravity(VALUE self)
{
    Info *info;
    const char *gravity;
    ID gravity_id;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    gravity_id = rb_intern("UndefinedGravity");

    // Map the gravity option string to a GravityType enumerator.
    gravity = GetImageOption(info, "gravity");
    if (gravity)
    {
        for (int x = 0; x < N_GRAVITY_OPTIONS; x++)
        {
            if (strcmp(gravity, Gravity_Option[x].string) == 0)
            {
                gravity_id = rb_intern(Gravity_Option[x].enum_name);
                break;
            }
        }
    }

    return rb_const_get(Module_Magick, gravity_id);
}

#gravity=(grav) ⇒ Object



1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
# File 'ext/RMagick/rminfo.cpp', line 1428

VALUE
Info_gravity_eq(VALUE self, VALUE grav)
{
    Info *info;
    GravityType gravity;
    const char *option;
    int x;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(grav))
    {
        DeleteImageOption(info, "gravity");
        return grav;
    }

    VALUE_TO_ENUM(grav, gravity, GravityType);
    option = "Undefined";

    for (x = 0; x < N_GRAVITY_OPTIONS; x++)
    {
        if (gravity == Gravity_Option[x].enumerator)
        {
            option = Gravity_Option[x].string;
            break;
        }
    }

    SetImageOption(info, "gravity", option);
    return grav;
}

#image_typeObject



1466
1467
1468
1469
1470
1471
1472
1473
# File 'ext/RMagick/rminfo.cpp', line 1466

VALUE
Info_image_type(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return ImageType_find(info->type);
}

#image_type=(type) ⇒ Object



1481
1482
1483
1484
1485
1486
1487
1488
1489
# File 'ext/RMagick/rminfo.cpp', line 1481

VALUE
Info_image_type_eq(VALUE self, VALUE type)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    VALUE_TO_ENUM(type, info->type, ImageType);
    return type;
}

#interlaceObject



1496
1497
1498
1499
1500
1501
1502
1503
# File 'ext/RMagick/rminfo.cpp', line 1496

VALUE
Info_interlace(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return InterlaceType_find(info->interlace);
}

#interlace=(inter) ⇒ Object



1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'ext/RMagick/rminfo.cpp', line 1511

VALUE
Info_interlace_eq(VALUE self, VALUE inter)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    VALUE_TO_ENUM(inter, info->interlace, InterlaceType);
    return inter;
}

#labelObject



1526
1527
1528
1529
# File 'ext/RMagick/rminfo.cpp', line 1526

VALUE Info_label(VALUE self)
{
    return get_option(self, "Label");
}

#label=(string) ⇒ Object



1537
1538
1539
1540
# File 'ext/RMagick/rminfo.cpp', line 1537

VALUE Info_label_eq(VALUE self, VALUE string)
{
    return set_option(self, "Label", string);
}

#matte_colorObject



1548
1549
1550
1551
1552
1553
1554
1555
# File 'ext/RMagick/rminfo.cpp', line 1548

VALUE
Info_matte_color(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return rm_pixelcolor_to_color_name_info(info, &info->matte_color);
}

#matte_color=(matte_arg) ⇒ Object



1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
# File 'ext/RMagick/rminfo.cpp', line 1563

VALUE
Info_matte_color_eq(VALUE self, VALUE matte_arg)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    Color_to_PixelColor(&info->matte_color, matte_arg);

    return matte_arg;
}

#monochromeObject



1579
1580
1581
1582
1583
# File 'ext/RMagick/rminfo.cpp', line 1579

VALUE
Info_monochrome(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, monochrome, boolean, &rm_info_data_type);
}

#monochrome=(val) ⇒ Object



1591
1592
1593
1594
1595
# File 'ext/RMagick/rminfo.cpp', line 1591

VALUE
Info_monochrome_eq(VALUE self, VALUE val)
{
    IMPLEMENT_TYPED_ATTR_WRITER(Info, monochrome, boolean, &rm_info_data_type);
}

#number_scenesObject



1602
1603
1604
1605
1606
# File 'ext/RMagick/rminfo.cpp', line 1602

VALUE
Info_number_scenes(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, number_scenes, ulong, &rm_info_data_type);
}

#number_scenes=(val) ⇒ Object



1614
1615
1616
1617
1618
# File 'ext/RMagick/rminfo.cpp', line 1614

VALUE
Info_number_scenes_eq(VALUE self, VALUE val)
{
    IMPLEMENT_TYPED_ATTR_WRITER(Info, number_scenes, ulong, &rm_info_data_type);
}

#orientationObject



1625
1626
1627
1628
1629
1630
1631
1632
# File 'ext/RMagick/rminfo.cpp', line 1625

VALUE
Info_orientation(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return OrientationType_find(info->orientation);
}

#orientation=(inter) ⇒ Object



1641
1642
1643
1644
1645
1646
1647
1648
1649
# File 'ext/RMagick/rminfo.cpp', line 1641

VALUE
Info_orientation_eq(VALUE self, VALUE inter)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    VALUE_TO_ENUM(inter, info->orientation, OrientationType);
    return inter;
}

#originString

Return origin geometry.

Returns:

  • (String)

    the origin geometry

See Also:



1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
# File 'ext/RMagick/rminfo.cpp', line 1658

VALUE
Info_origin(VALUE self)
{
    Info *info;
    const char *origin;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    origin = GetImageOption(info, "origin");
    return origin ? rb_str_new2(origin) : Qnil;
}

#origin=(origin_arg) ⇒ Magick::Geometry, String

Set origin geometry. Argument may be a Geometry object as well as a geometry string.

The geometry format is +-x+-y

Parameters:

Returns:

See Also:



1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
# File 'ext/RMagick/rminfo.cpp', line 1682

VALUE
Info_origin_eq(VALUE self, VALUE origin_arg)
{
    Info *info;
    VALUE origin_str;
    char *origin;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(origin_arg))
    {
        DeleteImageOption(info, "origin");
        return origin_arg;
    }

    origin_str = rb_String(origin_arg);
    origin = GetPageGeometry(StringValueCStr(origin_str));

    if (IsGeometry(origin) == MagickFalse)
    {
        magick_free(origin);
        rb_raise(rb_eArgError, "invalid origin geometry");
    }

    SetImageOption(info, "origin", origin);
    magick_free(origin);

    RB_GC_GUARD(origin_str);

    return origin_arg;
}

#pageString

Get the Postscript page geometry.

Returns:

  • (String)

    the page geometry



1720
1721
1722
1723
1724
1725
1726
1727
1728
# File 'ext/RMagick/rminfo.cpp', line 1720

VALUE
Info_page(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return info->page ? rb_str_new2(info->page) : Qnil;

}

#page=(page_arg) ⇒ Object



1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
# File 'ext/RMagick/rminfo.cpp', line 1738

VALUE
Info_page_eq(VALUE self, VALUE page_arg)
{
    Info *info;
    VALUE geom_str;
    char *geometry;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    if (NIL_P(page_arg))
    {
        magick_free(info->page);
        info->page = NULL;
        return page_arg;
    }
    geom_str = rb_String(page_arg);
    geometry = GetPageGeometry(StringValueCStr(geom_str));
    if (*geometry == '\0')
    {
        magick_free(info->page);
        info->page = NULL;
        return page_arg;
    }
    magick_free(info->page);

    info->page = geometry;

    RB_GC_GUARD(geom_str);

    return page_arg;
}

#pointsizeObject



1774
1775
1776
1777
1778
# File 'ext/RMagick/rminfo.cpp', line 1774

VALUE
Info_pointsize(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, pointsize, dbl, &rm_info_data_type);
}

#pointsize=(val) ⇒ Object



1786
1787
1788
1789
1790
# File 'ext/RMagick/rminfo.cpp', line 1786

VALUE
Info_pointsize_eq(VALUE self, VALUE val)
{
    IMPLEMENT_TYPED_ATTR_WRITER(Info, pointsize, dbl, &rm_info_data_type);
}

#qualityObject



1797
1798
1799
1800
1801
# File 'ext/RMagick/rminfo.cpp', line 1797

VALUE
Info_quality(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, quality, ulong, &rm_info_data_type);
}

#quality=(val) ⇒ Object



1809
1810
1811
1812
1813
# File 'ext/RMagick/rminfo.cpp', line 1809

VALUE
Info_quality_eq(VALUE self, VALUE val)
{
    IMPLEMENT_TYPED_ATTR_WRITER(Info, quality, ulong, &rm_info_data_type);
}

#sampling_factorObject



1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
# File 'ext/RMagick/rminfo.cpp', line 1820

VALUE
Info_sampling_factor(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    if (info->sampling_factor)
    {
        return rb_str_new2(info->sampling_factor);
    }
    else
    {
        return Qnil;
    }
}

#sampling_factor=(sampling_factor) ⇒ Object



1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
# File 'ext/RMagick/rminfo.cpp', line 1842

VALUE
Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
{
    Info *info;
    char *sampling_factor_p = NULL;
    size_t sampling_factor_len = 0;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (!NIL_P(sampling_factor))
    {
        sampling_factor_p = rm_str2cstr(&sampling_factor, &sampling_factor_len);
    }

    if (info->sampling_factor)
    {
        magick_free(info->sampling_factor);
        info->sampling_factor = NULL;
    }
    if (sampling_factor_len > 0)
    {
        magick_clone_string(&info->sampling_factor, sampling_factor_p);
    }

    return sampling_factor;
}

#sceneObject



1875
1876
1877
1878
1879
1880
1881
1882
# File 'ext/RMagick/rminfo.cpp', line 1875

VALUE
Info_scene(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return  ULONG2NUM(info->scene);
}

#scene=(scene) ⇒ Object



1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
# File 'ext/RMagick/rminfo.cpp', line 1891

VALUE
Info_scene_eq(VALUE self, VALUE scene)
{
    Info *info;
    char buf[25];

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    info->scene = NUM2ULONG(scene);

    snprintf(buf, sizeof(buf), "%" RMIuSIZE "", info->scene);
    SetImageOption(info, "scene", buf);

    return scene;
}

#server_nameObject



1912
1913
1914
1915
1916
# File 'ext/RMagick/rminfo.cpp', line 1912

VALUE
Info_server_name(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, server_name, str, &rm_info_data_type);
}

#server_name=(server_arg) ⇒ Object



1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
# File 'ext/RMagick/rminfo.cpp', line 1925

VALUE
Info_server_name_eq(VALUE self, VALUE server_arg)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    if (NIL_P(server_arg) || StringValueCStr(server_arg) == NULL)
    {
        magick_free(info->server_name);
        info->server_name = NULL;
    }
    else
    {
        char *server;

        server = StringValueCStr(server_arg);
        magick_clone_string(&info->server_name, server);
    }
    return server_arg;
}

#sizeObject



1952
1953
1954
1955
1956
# File 'ext/RMagick/rminfo.cpp', line 1952

VALUE
Info_size(VALUE self)
{
    IMPLEMENT_TYPED_ATTR_READER(Info, size, str, &rm_info_data_type);
}

#size=(size_arg) ⇒ Object



1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
# File 'ext/RMagick/rminfo.cpp', line 1965

VALUE
Info_size_eq(VALUE self, VALUE size_arg)
{
    Info *info;
    VALUE size;
    char *sz;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (NIL_P(size_arg))
    {
        magick_free(info->size);
        info->size = NULL;
        return size_arg;
    }

    size = rb_String(size_arg);
    sz = StringValueCStr(size);
    if (!IsGeometry(sz))
    {
        rb_raise(rb_eArgError, "invalid size geometry: %s", sz);
    }

    magick_clone_string(&info->size, sz);

    RB_GC_GUARD(size);

    return size_arg;
}

#strokeObject



2001
2002
2003
2004
2005
# File 'ext/RMagick/rminfo.cpp', line 2001

VALUE
Info_stroke(VALUE self)
{
    return get_option(self, "stroke");
}

#stroke=(color) ⇒ Object



2013
2014
2015
2016
2017
# File 'ext/RMagick/rminfo.cpp', line 2013

VALUE
Info_stroke_eq(VALUE self, VALUE color)
{
    return set_color_option(self, "stroke", color);
}

#stroke_widthObject



2025
2026
2027
2028
2029
# File 'ext/RMagick/rminfo.cpp', line 2025

VALUE
Info_stroke_width(VALUE self)
{
    return get_dbl_option(self, "strokewidth");
}

#stroke_width=(stroke_width) ⇒ Object



2038
2039
2040
2041
2042
# File 'ext/RMagick/rminfo.cpp', line 2038

VALUE
Info_stroke_width_eq(VALUE self, VALUE stroke_width)
{
    return set_dbl_option(self, "strokewidth", stroke_width);
}

#texture=(texture) ⇒ Object



2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
# File 'ext/RMagick/rminfo.cpp', line 2051

VALUE
Info_texture_eq(VALUE self, VALUE texture)
{
    Info *info;
    Image *image;
    char name[MaxTextExtent];

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    // Delete any existing texture file
    if (info->texture)
    {
        rm_delete_temp_image(info->texture);
        magick_free(info->texture);
        info->texture = NULL;
    }

    // If argument is nil we're done
    if (texture == Qnil)
    {
        return texture;
    }

    // Create a temp copy of the texture and store its name in the texture field
    image = rm_check_destroyed(texture);
    rm_write_temp_image(image, name, sizeof(name));

    magick_clone_string(&info->texture, name);

    return texture;
}

#tile_offsetObject



2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
# File 'ext/RMagick/rminfo.cpp', line 2090

VALUE
Info_tile_offset(VALUE self)
{
    Info *info;
    const char *tile_offset;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    tile_offset = GetImageOption(info, "tile-offset");

    if (!tile_offset)
    {
        return Qnil;
    }

    return rb_str_new2(tile_offset);
}

#tile_offset=(offset) ⇒ Object



2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
# File 'ext/RMagick/rminfo.cpp', line 2116

VALUE
Info_tile_offset_eq(VALUE self, VALUE offset)
{
    Info *info;
    VALUE offset_str;
    char *tile_offset;

    offset_str = rb_String(offset);
    tile_offset = StringValueCStr(offset_str);
    if (!IsGeometry(tile_offset))
    {
        rb_raise(rb_eArgError, "invalid tile offset geometry: %s", tile_offset);
    }

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    DeleteImageOption(info, "tile-offset");
    SetImageOption(info, "tile-offset", tile_offset);

    RB_GC_GUARD(offset_str);

    return offset;
}

#transparent_colorObject



2147
2148
2149
2150
2151
2152
2153
2154
# File 'ext/RMagick/rminfo.cpp', line 2147

VALUE
Info_transparent_color(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return rm_pixelcolor_to_color_name_info(info, &info->transparent_color);
}

#transparent_color=(tc_arg) ⇒ Object



2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
# File 'ext/RMagick/rminfo.cpp', line 2163

VALUE
Info_transparent_color_eq(VALUE self, VALUE tc_arg)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    Color_to_PixelColor(&info->transparent_color, tc_arg);

    return tc_arg;
}

#undefine(format, key) ⇒ Object



2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
# File 'ext/RMagick/rminfo.cpp', line 2182

VALUE
Info_undefine(VALUE self, VALUE format, VALUE key)
{
    Info *info;
    char *format_p, *key_p;
    size_t format_l, key_l;
    char fkey[MaxTextExtent];

    format_p = rm_str2cstr(&format, &format_l);
    key_p = rm_str2cstr(&key, &key_l);

    if (format_l > MAX_FORMAT_LEN || format_l + key_l > MaxTextExtent)
    {
        rb_raise(rb_eArgError, "can't undefine %.60s:%.1024s - too long", format_p, key_p);
    }

    snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    DeleteImageOption(info, fkey);

    return self;
}

#undercolorObject



2212
2213
2214
2215
2216
# File 'ext/RMagick/rminfo.cpp', line 2212

VALUE
Info_undercolor(VALUE self)
{
    return get_option(self, "undercolor");
}

#undercolor=(color) ⇒ Object



2224
2225
2226
2227
2228
# File 'ext/RMagick/rminfo.cpp', line 2224

VALUE
Info_undercolor_eq(VALUE self, VALUE color)
{
    return set_color_option(self, "undercolor", color);
}

#unitsObject



2235
2236
2237
2238
2239
2240
2241
2242
# File 'ext/RMagick/rminfo.cpp', line 2235

VALUE
Info_units(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    return ResolutionType_find(info->units);
}

#units=(units) ⇒ Object



2250
2251
2252
2253
2254
2255
2256
2257
2258
# File 'ext/RMagick/rminfo.cpp', line 2250

VALUE
Info_units_eq(VALUE self, VALUE units)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
    VALUE_TO_ENUM(units, info->units, ResolutionType);
    return units;
}

#viewObject



2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
# File 'ext/RMagick/rminfo.cpp', line 2265

VALUE
Info_view(VALUE self)
{
    Info *info;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);
#if defined(IMAGEMAGICK_7)
    return C_str_to_R_str(GetImageOption(info, "fpx:view"));
#else
    return C_str_to_R_str(info->view);
#endif
}

#view=(view_arg) ⇒ Object



2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
# File 'ext/RMagick/rminfo.cpp', line 2284

VALUE
Info_view_eq(VALUE self, VALUE view_arg)
{
    Info *info;
    char *view = NULL;

    TypedData_Get_Struct(self, Info, &rm_info_data_type, info);

    if (!NIL_P(view_arg))
    {
        view = StringValueCStr(view_arg);
    }

#if defined(IMAGEMAGICK_7)
    if (view)
    {
        SetImageOption(info, "fpx:view", view);
    }
    else
    {
        DeleteImageOption(info, "fpx:view");
    }
#else
    if (info->view)
    {
        magick_free(info->view);
        info->view = NULL;
    }
    if (view)
    {
        magick_clone_string(&info->view, view);
    }
#endif
    return view_arg;
}