rmagick 3.2.0 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.codeclimate.yml +63 -0
- data/.devcontainer/Dockerfile +14 -0
- data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
- data/.devcontainer/devcontainer.json +11 -0
- data/.devcontainer/setup-repo.sh +10 -0
- data/.devcontainer/setup-user.sh +45 -0
- data/.editorconfig +3 -0
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/.github/workflows/ci.yml +79 -0
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/.rubocop.yml +24 -0
- data/.rubocop_todo.yml +151 -297
- data/.yardopts +5 -0
- data/CHANGELOG.md +233 -0
- data/CODE_OF_CONDUCT.md +122 -7
- data/CONTRIBUTING.md +14 -10
- data/README.md +326 -0
- data/Rakefile +16 -22
- data/before_install_linux.sh +22 -28
- data/before_install_osx.sh +57 -2
- data/ext/RMagick/extconf.rb +149 -105
- data/ext/RMagick/rmagick.c +77 -104
- data/ext/RMagick/rmagick.h +121 -103
- data/ext/RMagick/rmdraw.c +364 -436
- data/ext/RMagick/rmenum.c +106 -114
- data/ext/RMagick/rmfill.c +149 -70
- data/ext/RMagick/rmilist.c +225 -367
- data/ext/RMagick/rmimage.c +4751 -4405
- data/ext/RMagick/rminfo.c +574 -787
- data/ext/RMagick/rmkinfo.c +51 -121
- data/ext/RMagick/rmmain.c +454 -286
- data/ext/RMagick/rmmontage.c +64 -130
- data/ext/RMagick/rmpixel.c +488 -437
- data/ext/RMagick/rmstruct.c +83 -96
- data/ext/RMagick/rmutil.c +302 -214
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +138 -93
- data/lib/rvg/clippath.rb +2 -1
- data/lib/rvg/container.rb +10 -5
- data/lib/rvg/describable.rb +1 -1
- data/lib/rvg/embellishable.rb +5 -4
- data/lib/rvg/misc.rb +15 -12
- data/lib/rvg/paint.rb +2 -1
- data/lib/rvg/pathdata.rb +12 -11
- data/lib/rvg/rvg.rb +12 -8
- data/lib/rvg/stylable.rb +9 -7
- data/lib/rvg/text.rb +11 -6
- data/lib/rvg/transformable.rb +3 -2
- data/lib/rvg/units.rb +1 -1
- data/rmagick.gemspec +10 -11
- metadata +52 -423
- data/.appveyor.yml +0 -45
- data/.circleci/config.yml +0 -56
- data/.ruby-version +0 -1
- data/.simplecov +0 -27
- data/.travis.yml +0 -62
- data/Doxyfile +0 -1514
- data/README.textile +0 -259
- data/benchmarks/memory/README.md +0 -50
- data/benchmarks/memory/image_new.rb +0 -8
- data/benchmarks/memory/rmagick.gnuplot +0 -16
- data/doc/.cvsignore +0 -1
- data/doc/comtasks.html +0 -287
- data/doc/constants.html +0 -1581
- data/doc/css/doc.css +0 -299
- data/doc/css/popup.css +0 -34
- data/doc/css/ref.css +0 -67
- data/doc/draw.html +0 -3272
- data/doc/ex/InitialCoords.rb +0 -22
- data/doc/ex/NewCoordSys.rb +0 -30
- data/doc/ex/OrigCoordSys.rb +0 -16
- data/doc/ex/PreserveAspectRatio.rb +0 -204
- data/doc/ex/RotateScale.rb +0 -36
- data/doc/ex/Skew.rb +0 -38
- data/doc/ex/Use01.rb +0 -15
- data/doc/ex/Use02.rb +0 -20
- data/doc/ex/Use03.rb +0 -16
- data/doc/ex/ViewBox.rb +0 -31
- data/doc/ex/adaptive_threshold.rb +0 -9
- data/doc/ex/add_noise.rb +0 -16
- data/doc/ex/affine.rb +0 -48
- data/doc/ex/affine_transform.rb +0 -20
- data/doc/ex/arc.rb +0 -49
- data/doc/ex/arcpath.rb +0 -32
- data/doc/ex/arcs01.rb +0 -28
- data/doc/ex/arcs02.rb +0 -59
- data/doc/ex/average.rb +0 -15
- data/doc/ex/axes.rb +0 -64
- data/doc/ex/baseline_shift01.rb +0 -17
- data/doc/ex/bilevel_channel.rb +0 -8
- data/doc/ex/blur_image.rb +0 -12
- data/doc/ex/border.rb +0 -10
- data/doc/ex/bounding_box.rb +0 -42
- data/doc/ex/cbezier1.rb +0 -41
- data/doc/ex/cbezier2.rb +0 -41
- data/doc/ex/cbezier3.rb +0 -41
- data/doc/ex/cbezier4.rb +0 -42
- data/doc/ex/cbezier5.rb +0 -42
- data/doc/ex/cbezier6.rb +0 -53
- data/doc/ex/channel.rb +0 -25
- data/doc/ex/charcoal.rb +0 -12
- data/doc/ex/chop.rb +0 -29
- data/doc/ex/circle.rb +0 -33
- data/doc/ex/circle01.rb +0 -16
- data/doc/ex/clip_path.rb +0 -60
- data/doc/ex/coalesce.rb +0 -57
- data/doc/ex/color_fill_to_border.rb +0 -29
- data/doc/ex/color_floodfill.rb +0 -28
- data/doc/ex/color_histogram.rb +0 -47
- data/doc/ex/color_reset.rb +0 -11
- data/doc/ex/colorize.rb +0 -16
- data/doc/ex/colors.rb +0 -64
- data/doc/ex/compose_mask.rb +0 -22
- data/doc/ex/composite.rb +0 -133
- data/doc/ex/composite_layers.rb +0 -52
- data/doc/ex/composite_tiled.rb +0 -21
- data/doc/ex/contrast.rb +0 -36
- data/doc/ex/crop.rb +0 -31
- data/doc/ex/crop_with_gravity.rb +0 -42
- data/doc/ex/cubic01.rb +0 -43
- data/doc/ex/cubic02.rb +0 -91
- data/doc/ex/cycle_colormap.rb +0 -21
- data/doc/ex/dissolve.rb +0 -12
- data/doc/ex/drawcomp.rb +0 -41
- data/doc/ex/drop_shadow.rb +0 -60
- data/doc/ex/edge.rb +0 -11
- data/doc/ex/ellipse.rb +0 -45
- data/doc/ex/ellipse01.rb +0 -21
- data/doc/ex/emboss.rb +0 -11
- data/doc/ex/enhance.rb +0 -28
- data/doc/ex/equalize.rb +0 -11
- data/doc/ex/evenodd.rb +0 -42
- data/doc/ex/fill_pattern.rb +0 -23
- data/doc/ex/flatten_images.rb +0 -36
- data/doc/ex/flip.rb +0 -11
- data/doc/ex/flop.rb +0 -11
- data/doc/ex/font_styles.rb +0 -32
- data/doc/ex/fonts.rb +0 -16
- data/doc/ex/frame.rb +0 -12
- data/doc/ex/gaussian_blur.rb +0 -11
- data/doc/ex/get_multiline_type_metrics.rb +0 -41
- data/doc/ex/get_pixels.rb +0 -45
- data/doc/ex/get_type_metrics.rb +0 -142
- data/doc/ex/gradientfill.rb +0 -27
- data/doc/ex/grav.rb +0 -45
- data/doc/ex/gravity.rb +0 -78
- data/doc/ex/group.rb +0 -26
- data/doc/ex/hatchfill.rb +0 -27
- data/doc/ex/image.rb +0 -44
- data/doc/ex/images/Apple.miff +0 -0
- data/doc/ex/images/Ballerina.jpg +0 -0
- data/doc/ex/images/Ballerina3.jpg +0 -0
- data/doc/ex/images/Button_0.gif +0 -0
- data/doc/ex/images/Button_1.gif +0 -0
- data/doc/ex/images/Button_2.gif +0 -0
- data/doc/ex/images/Button_3.gif +0 -0
- data/doc/ex/images/Button_4.gif +0 -0
- data/doc/ex/images/Button_5.gif +0 -0
- data/doc/ex/images/Button_6.gif +0 -0
- data/doc/ex/images/Button_7.gif +0 -0
- data/doc/ex/images/Button_8.gif +0 -0
- data/doc/ex/images/Button_9.gif +0 -0
- data/doc/ex/images/Button_A.gif +0 -0
- data/doc/ex/images/Button_B.gif +0 -0
- data/doc/ex/images/Button_C.gif +0 -0
- data/doc/ex/images/Button_D.gif +0 -0
- data/doc/ex/images/Button_E.gif +0 -0
- data/doc/ex/images/Button_F.gif +0 -0
- data/doc/ex/images/Button_G.gif +0 -0
- data/doc/ex/images/Button_H.gif +0 -0
- data/doc/ex/images/Button_I.gif +0 -0
- data/doc/ex/images/Button_J.gif +0 -0
- data/doc/ex/images/Button_K.gif +0 -0
- data/doc/ex/images/Button_L.gif +0 -0
- data/doc/ex/images/Button_M.gif +0 -0
- data/doc/ex/images/Button_N.gif +0 -0
- data/doc/ex/images/Button_O.gif +0 -0
- data/doc/ex/images/Button_P.gif +0 -0
- data/doc/ex/images/Button_Q.gif +0 -0
- data/doc/ex/images/Button_R.gif +0 -0
- data/doc/ex/images/Button_S.gif +0 -0
- data/doc/ex/images/Button_T.gif +0 -0
- data/doc/ex/images/Button_U.gif +0 -0
- data/doc/ex/images/Button_V.gif +0 -0
- data/doc/ex/images/Button_W.gif +0 -0
- data/doc/ex/images/Button_X.gif +0 -0
- data/doc/ex/images/Button_Y.gif +0 -0
- data/doc/ex/images/Button_Z.gif +0 -0
- data/doc/ex/images/Cheetah.jpg +0 -0
- data/doc/ex/images/Coffee.png +0 -0
- data/doc/ex/images/Flower_Hat.jpg +0 -0
- data/doc/ex/images/Gold_Statue.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
- data/doc/ex/images/Leaf.miff +0 -0
- data/doc/ex/images/No.png +0 -0
- data/doc/ex/images/Polynesia.jpg +0 -0
- data/doc/ex/images/Red_Rocks.jpg +0 -0
- data/doc/ex/images/Rocks_On_Beach.miff +0 -0
- data/doc/ex/images/Shorts.jpg +0 -0
- data/doc/ex/images/Snake.png +0 -0
- data/doc/ex/images/Violin.jpg +0 -0
- data/doc/ex/images/Yellow_Rose.miff +0 -0
- data/doc/ex/images/big-duck.gif +0 -0
- data/doc/ex/images/duck.gif +0 -0
- data/doc/ex/images/duck0.gif +0 -0
- data/doc/ex/images/duck1.gif +0 -0
- data/doc/ex/images/duck10.gif +0 -0
- data/doc/ex/images/duck11.gif +0 -0
- data/doc/ex/images/duck12.gif +0 -0
- data/doc/ex/images/duck13.gif +0 -0
- data/doc/ex/images/duck14.gif +0 -0
- data/doc/ex/images/duck15.gif +0 -0
- data/doc/ex/images/duck2.gif +0 -0
- data/doc/ex/images/duck3.gif +0 -0
- data/doc/ex/images/duck4.gif +0 -0
- data/doc/ex/images/duck5.gif +0 -0
- data/doc/ex/images/duck6.gif +0 -0
- data/doc/ex/images/duck7.gif +0 -0
- data/doc/ex/images/duck8.gif +0 -0
- data/doc/ex/images/duck9.gif +0 -0
- data/doc/ex/images/graydient230x6.gif +0 -0
- data/doc/ex/images/image_with_profile.jpg +0 -0
- data/doc/ex/images/logo400x83.gif +0 -0
- data/doc/ex/images/model.miff +0 -0
- data/doc/ex/images/notimplemented.gif +0 -0
- data/doc/ex/images/smile.miff +0 -0
- data/doc/ex/images/spin.gif +0 -0
- data/doc/ex/implode.rb +0 -34
- data/doc/ex/level.rb +0 -11
- data/doc/ex/level_colors.rb +0 -11
- data/doc/ex/line.rb +0 -41
- data/doc/ex/line01.rb +0 -21
- data/doc/ex/mask.rb +0 -35
- data/doc/ex/matte_fill_to_border.rb +0 -39
- data/doc/ex/matte_floodfill.rb +0 -32
- data/doc/ex/matte_replace.rb +0 -39
- data/doc/ex/median_filter.rb +0 -28
- data/doc/ex/modulate.rb +0 -11
- data/doc/ex/mono.rb +0 -23
- data/doc/ex/morph.rb +0 -25
- data/doc/ex/mosaic.rb +0 -37
- data/doc/ex/motion_blur.rb +0 -11
- data/doc/ex/negate.rb +0 -11
- data/doc/ex/negate_channel.rb +0 -9
- data/doc/ex/nested_rvg.rb +0 -21
- data/doc/ex/nonzero.rb +0 -42
- data/doc/ex/normalize.rb +0 -11
- data/doc/ex/oil_paint.rb +0 -11
- data/doc/ex/opacity.rb +0 -37
- data/doc/ex/ordered_dither.rb +0 -11
- data/doc/ex/path.rb +0 -63
- data/doc/ex/pattern1.rb +0 -25
- data/doc/ex/pattern2.rb +0 -26
- data/doc/ex/polaroid.rb +0 -26
- data/doc/ex/polygon.rb +0 -23
- data/doc/ex/polygon01.rb +0 -21
- data/doc/ex/polyline.rb +0 -22
- data/doc/ex/polyline01.rb +0 -21
- data/doc/ex/posterize.rb +0 -8
- data/doc/ex/preview.rb +0 -8
- data/doc/ex/qbezierpath.rb +0 -52
- data/doc/ex/quad01.rb +0 -34
- data/doc/ex/quantize-m.rb +0 -25
- data/doc/ex/radial_blur.rb +0 -9
- data/doc/ex/raise.rb +0 -8
- data/doc/ex/random_threshold_channel.rb +0 -13
- data/doc/ex/rect01.rb +0 -14
- data/doc/ex/rect02.rb +0 -20
- data/doc/ex/rectangle.rb +0 -34
- data/doc/ex/reduce_noise.rb +0 -28
- data/doc/ex/remap.rb +0 -11
- data/doc/ex/remap_images.rb +0 -19
- data/doc/ex/resize_to_fill.rb +0 -8
- data/doc/ex/resize_to_fit.rb +0 -8
- data/doc/ex/roll.rb +0 -9
- data/doc/ex/rotate.rb +0 -44
- data/doc/ex/rotate_f.rb +0 -14
- data/doc/ex/roundrect.rb +0 -33
- data/doc/ex/rubyname.rb +0 -30
- data/doc/ex/rvg_clippath.rb +0 -12
- data/doc/ex/rvg_linecap.rb +0 -42
- data/doc/ex/rvg_linejoin.rb +0 -40
- data/doc/ex/rvg_opacity.rb +0 -18
- data/doc/ex/rvg_pattern.rb +0 -26
- data/doc/ex/rvg_stroke_dasharray.rb +0 -11
- data/doc/ex/segment.rb +0 -11
- data/doc/ex/sepiatone.rb +0 -7
- data/doc/ex/shade.rb +0 -11
- data/doc/ex/shadow.rb +0 -30
- data/doc/ex/shave.rb +0 -15
- data/doc/ex/shear.rb +0 -10
- data/doc/ex/sketch.rb +0 -17
- data/doc/ex/skewx.rb +0 -51
- data/doc/ex/skewy.rb +0 -47
- data/doc/ex/smile.rb +0 -126
- data/doc/ex/solarize.rb +0 -11
- data/doc/ex/sparse_color.rb +0 -55
- data/doc/ex/splice.rb +0 -8
- data/doc/ex/spread.rb +0 -11
- data/doc/ex/stegano.rb +0 -54
- data/doc/ex/stroke_dasharray.rb +0 -42
- data/doc/ex/stroke_fill.rb +0 -10
- data/doc/ex/stroke_linecap.rb +0 -44
- data/doc/ex/stroke_linejoin.rb +0 -48
- data/doc/ex/stroke_width.rb +0 -49
- data/doc/ex/swirl.rb +0 -17
- data/doc/ex/text.rb +0 -37
- data/doc/ex/text01.rb +0 -16
- data/doc/ex/text_align.rb +0 -36
- data/doc/ex/text_antialias.rb +0 -37
- data/doc/ex/text_styles.rb +0 -19
- data/doc/ex/text_undercolor.rb +0 -28
- data/doc/ex/texture_fill_to_border.rb +0 -34
- data/doc/ex/texture_floodfill.rb +0 -32
- data/doc/ex/texturefill.rb +0 -24
- data/doc/ex/threshold.rb +0 -13
- data/doc/ex/to_blob.rb +0 -13
- data/doc/ex/translate.rb +0 -39
- data/doc/ex/transparent.rb +0 -38
- data/doc/ex/transpose.rb +0 -9
- data/doc/ex/transverse.rb +0 -9
- data/doc/ex/tref01.rb +0 -24
- data/doc/ex/triangle01.rb +0 -15
- data/doc/ex/trim.rb +0 -23
- data/doc/ex/tspan01.rb +0 -17
- data/doc/ex/tspan02.rb +0 -17
- data/doc/ex/tspan03.rb +0 -19
- data/doc/ex/unsharp_mask.rb +0 -28
- data/doc/ex/viewex.rb +0 -33
- data/doc/ex/vignette.rb +0 -12
- data/doc/ex/watermark.rb +0 -27
- data/doc/ex/wave.rb +0 -9
- data/doc/ex/wet_floor.rb +0 -58
- data/doc/ex/writing_mode01.rb +0 -26
- data/doc/ex/writing_mode02.rb +0 -26
- data/doc/ilist.html +0 -2056
- data/doc/image1.html +0 -4680
- data/doc/image2.html +0 -3665
- data/doc/image3.html +0 -4522
- data/doc/imageattrs.html +0 -1638
- data/doc/imusage.html +0 -514
- data/doc/index.html +0 -416
- data/doc/info.html +0 -1499
- data/doc/magick.html +0 -570
- data/doc/optequiv.html +0 -2435
- data/doc/rvg.html +0 -975
- data/doc/rvgclip.html +0 -248
- data/doc/rvggroup.html +0 -305
- data/doc/rvgimage.html +0 -289
- data/doc/rvgpattern.html +0 -475
- data/doc/rvgshape.html +0 -406
- data/doc/rvgstyle.html +0 -270
- data/doc/rvgtext.html +0 -465
- data/doc/rvgtspan.html +0 -238
- data/doc/rvgtut.html +0 -530
- data/doc/rvguse.html +0 -145
- data/doc/rvgxform.html +0 -294
- data/doc/scripts/doc.js +0 -22
- data/doc/scripts/stripeTables.js +0 -23
- data/doc/struct.html +0 -1339
- data/doc/usage.html +0 -1621
- data/examples/constitute.rb +0 -7
- data/examples/crop_with_gravity.rb +0 -42
- data/examples/demo.rb +0 -323
- data/examples/describe.rb +0 -41
- data/examples/find_similar_region.rb +0 -34
- data/examples/histogram.rb +0 -312
- data/examples/identify.rb +0 -174
- data/examples/image_opacity.rb +0 -28
- data/examples/import_export.rb +0 -31
- data/examples/pattern_fill.rb +0 -37
- data/examples/rotating_text.rb +0 -45
- data/examples/spinner.rb +0 -49
- data/examples/thumbnail.rb +0 -64
- data/examples/vignette.rb +0 -78
- data/lib/obsolete.rb +0 -66
- data/spec/rmagick/ImageList1_spec.rb +0 -24
- data/spec/rmagick/draw_spec.rb +0 -155
- data/spec/rmagick/image/blue_shift_spec.rb +0 -14
- data/spec/rmagick/image/channel_entropy_spec.rb +0 -9
- data/spec/rmagick/image/composite_spec.rb +0 -72
- data/spec/rmagick/image/constitute_spec.rb +0 -13
- data/spec/rmagick/image/dispatch_spec.rb +0 -16
- data/spec/rmagick/image/from_blob_spec.rb +0 -12
- data/spec/rmagick/image/ping_spec.rb +0 -12
- data/spec/rmagick/image/properties_spec.rb +0 -27
- data/spec/rmagick/image/read_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -10
- data/spec/support/issue_200/app.rb +0 -8
- data/test/Draw.rb +0 -351
- data/test/Enum.rb +0 -228
- data/test/Fill.rb +0 -93
- data/test/Image1.rb +0 -627
- data/test/Image2.rb +0 -1426
- data/test/Image3.rb +0 -1091
- data/test/ImageList1.rb +0 -858
- data/test/ImageList2.rb +0 -406
- data/test/Image_attributes.rb +0 -666
- data/test/Import_Export.rb +0 -115
- data/test/Info.rb +0 -444
- data/test/KernelInfo.rb +0 -67
- data/test/Magick.rb +0 -311
- data/test/Pixel.rb +0 -285
- data/test/PolaroidOptions.rb +0 -23
- data/test/Preview.rb +0 -26
- data/test/Struct.rb +0 -45
- data/test/appearance/Montage.rb +0 -26
- data/test/appearance/appearance_assertion.rb +0 -13
- data/test/appearance/expected/montage_border_color.jpg +0 -0
- data/test/cmyk.icm +0 -0
- data/test/lib/Obsolete.rb +0 -30
- data/test/lib/internal/Draw.rb +0 -823
- data/test/lib/internal/Geometry.rb +0 -98
- data/test/lib/internal/Magick.rb +0 -40
- data/test/srgb.icm +0 -0
- data/test/test_all_basic.rb +0 -49
- data/test/tmpnam_test.rb +0 -50
data/ext/RMagick/rmutil.c
CHANGED
@@ -12,7 +12,13 @@
|
|
12
12
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
#include <errno.h>
|
15
|
+
#if defined(_WIN32)
|
16
|
+
#include <Windows.h>
|
17
|
+
#else
|
18
|
+
#include <pthread.h>
|
19
|
+
#endif
|
15
20
|
|
21
|
+
static VALUE rescue_not_str(VALUE, VALUE ATTRIBUTE_UNUSED) ATTRIBUTE_NORETURN;
|
16
22
|
static void handle_exception(ExceptionInfo *, Image *, ErrorRetention);
|
17
23
|
|
18
24
|
|
@@ -78,7 +84,7 @@ magick_malloc(const size_t size)
|
|
78
84
|
void
|
79
85
|
magick_free(void *ptr)
|
80
86
|
{
|
81
|
-
|
87
|
+
RelinquishMagickMemory(ptr);
|
82
88
|
}
|
83
89
|
|
84
90
|
|
@@ -112,28 +118,6 @@ magick_safe_realloc(void *memory, const size_t count, const size_t quantum)
|
|
112
118
|
}
|
113
119
|
|
114
120
|
|
115
|
-
/**
|
116
|
-
* ImageMagick version of realloc.
|
117
|
-
*
|
118
|
-
* No Ruby usage (internal function)
|
119
|
-
*
|
120
|
-
* @param ptr pointer to the existing block of memory
|
121
|
-
* @param size the new size of memory to allocate
|
122
|
-
* @return pointer to a block of memory
|
123
|
-
*/
|
124
|
-
void *
|
125
|
-
magick_realloc(void *ptr, const size_t size)
|
126
|
-
{
|
127
|
-
void *v;
|
128
|
-
v = ResizeMagickMemory(ptr, size);
|
129
|
-
if (!v)
|
130
|
-
{
|
131
|
-
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
132
|
-
}
|
133
|
-
return v;
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
121
|
/**
|
138
122
|
* Make a copy of a string in malloc'd memory.
|
139
123
|
*
|
@@ -149,7 +133,7 @@ magick_realloc(void *ptr, const size_t size)
|
|
149
133
|
void
|
150
134
|
magick_clone_string(char **new_str, const char *str)
|
151
135
|
{
|
152
|
-
|
136
|
+
CloneString(new_str, str);
|
153
137
|
}
|
154
138
|
|
155
139
|
|
@@ -208,6 +192,28 @@ rm_strncasecmp(const char *s1, const char *s2, size_t n)
|
|
208
192
|
}
|
209
193
|
|
210
194
|
|
195
|
+
/**
|
196
|
+
* Get string length.
|
197
|
+
*
|
198
|
+
* No Ruby usage (internal function)
|
199
|
+
*
|
200
|
+
* @param str the string
|
201
|
+
* @param strsz the maximum number of characters
|
202
|
+
* @return same as strnlen_s()
|
203
|
+
*/
|
204
|
+
size_t
|
205
|
+
rm_strnlen_s(const char *str, size_t strsz)
|
206
|
+
{
|
207
|
+
size_t length = 0;
|
208
|
+
while(*str && length < strsz)
|
209
|
+
{
|
210
|
+
str++;
|
211
|
+
length++;
|
212
|
+
}
|
213
|
+
return length;
|
214
|
+
}
|
215
|
+
|
216
|
+
|
211
217
|
/**
|
212
218
|
* Raise exception if array too short.
|
213
219
|
*
|
@@ -243,7 +249,7 @@ rm_check_ary_type(VALUE ary)
|
|
243
249
|
VALUE checked = rb_check_array_type(ary);
|
244
250
|
if (NIL_P(checked))
|
245
251
|
{
|
246
|
-
rb_raise(rb_eTypeError, "wrong argument type %"
|
252
|
+
rb_raise(rb_eTypeError, "wrong argument type %"RMIsVALUE" was given. (must respond to :to_ary)", rb_obj_class(ary));
|
247
253
|
}
|
248
254
|
return checked;
|
249
255
|
}
|
@@ -295,35 +301,12 @@ rm_check_frozen(VALUE obj)
|
|
295
301
|
*
|
296
302
|
* No Ruby usage (internal function)
|
297
303
|
*
|
298
|
-
* @
|
299
|
-
* @return 0
|
300
|
-
* @throw TypeError
|
304
|
+
* @raise [TypeError]
|
301
305
|
*/
|
302
306
|
VALUE
|
303
307
|
rm_no_freeze(VALUE obj)
|
304
308
|
{
|
305
309
|
rb_raise(rb_eTypeError, "can't freeze %s", rb_class2name(CLASS_OF(obj)));
|
306
|
-
return (VALUE)0;
|
307
|
-
}
|
308
|
-
|
309
|
-
|
310
|
-
/**
|
311
|
-
* Return obj.to_s, or obj if obj is already a string.
|
312
|
-
*
|
313
|
-
* No Ruby usage (internal function)
|
314
|
-
*
|
315
|
-
* @param obj a Ruby object
|
316
|
-
* @return a String representation of obj
|
317
|
-
*/
|
318
|
-
VALUE
|
319
|
-
rm_to_s(VALUE obj)
|
320
|
-
{
|
321
|
-
|
322
|
-
if (TYPE(obj) != T_STRING)
|
323
|
-
{
|
324
|
-
return rb_funcall(obj, rm_ID_to_s, 0);
|
325
|
-
}
|
326
|
-
return obj;
|
327
310
|
}
|
328
311
|
|
329
312
|
|
@@ -348,21 +331,6 @@ rm_str2cstr(VALUE str, long *len)
|
|
348
331
|
}
|
349
332
|
|
350
333
|
|
351
|
-
/**
|
352
|
-
* Try to convert the argument to a double, raise an exception if fail.
|
353
|
-
*
|
354
|
-
* No Ruby usage (internal function)
|
355
|
-
*
|
356
|
-
* @param arg the argument
|
357
|
-
* @return arg
|
358
|
-
*/
|
359
|
-
static VALUE
|
360
|
-
arg_is_number(VALUE arg)
|
361
|
-
{
|
362
|
-
return DBL2NUM(NUM2DBL(arg));
|
363
|
-
}
|
364
|
-
|
365
|
-
|
366
334
|
/**
|
367
335
|
* Called when `rb_str_to_str' raises an exception.
|
368
336
|
*
|
@@ -373,11 +341,10 @@ arg_is_number(VALUE arg)
|
|
373
341
|
* @throw TypeError
|
374
342
|
*/
|
375
343
|
static VALUE
|
376
|
-
rescue_not_str(VALUE arg)
|
344
|
+
rescue_not_str(VALUE arg, VALUE raised_exc ATTRIBUTE_UNUSED)
|
377
345
|
{
|
378
346
|
rb_raise(rb_eTypeError, "argument must be a number or a string in the form 'NN%%' (%s given)",
|
379
347
|
rb_class2name(CLASS_OF(arg)));
|
380
|
-
return (VALUE)0;
|
381
348
|
}
|
382
349
|
|
383
350
|
|
@@ -396,17 +363,15 @@ double
|
|
396
363
|
rm_percentage(VALUE arg, double max)
|
397
364
|
{
|
398
365
|
double pct;
|
399
|
-
|
400
|
-
char *pct_str, *end;
|
401
|
-
int not_num;
|
402
|
-
|
403
|
-
// Try to convert the argument to a number. If failure, sets not_num to non-zero.
|
404
|
-
(void) rb_protect(arg_is_number, arg, ¬_num);
|
366
|
+
char *end;
|
405
367
|
|
406
|
-
if (
|
368
|
+
if (!rm_check_num2dbl(arg))
|
407
369
|
{
|
370
|
+
char *pct_str;
|
371
|
+
long pct_long;
|
372
|
+
|
408
373
|
arg = rb_rescue(rb_str_to_str, arg, rescue_not_str, arg);
|
409
|
-
pct_str =
|
374
|
+
pct_str = StringValueCStr(arg);
|
410
375
|
errno = 0;
|
411
376
|
pct_long = strtol(pct_str, &end, 10);
|
412
377
|
if (errno == ERANGE)
|
@@ -455,7 +420,7 @@ rm_percentage(VALUE arg, double max)
|
|
455
420
|
static VALUE
|
456
421
|
check_num2dbl(VALUE obj)
|
457
422
|
{
|
458
|
-
|
423
|
+
rb_num2dbl(obj);
|
459
424
|
return INT2FIX(1);
|
460
425
|
}
|
461
426
|
|
@@ -469,7 +434,7 @@ check_num2dbl(VALUE obj)
|
|
469
434
|
* @return 0
|
470
435
|
*/
|
471
436
|
static VALUE
|
472
|
-
rescue_not_dbl(VALUE ignored ATTRIBUTE_UNUSED)
|
437
|
+
rescue_not_dbl(VALUE ignored ATTRIBUTE_UNUSED, VALUE raised_exc ATTRIBUTE_UNUSED)
|
473
438
|
{
|
474
439
|
return INT2FIX(0);
|
475
440
|
}
|
@@ -505,7 +470,7 @@ rm_str_to_pct(VALUE str)
|
|
505
470
|
char *pct_str, *end;
|
506
471
|
|
507
472
|
str = rb_rescue(rb_str_to_str, str, rescue_not_str, str);
|
508
|
-
pct_str =
|
473
|
+
pct_str = StringValueCStr(str);
|
509
474
|
errno = 0;
|
510
475
|
pct = strtol(pct_str, &end, 10);
|
511
476
|
|
@@ -541,17 +506,15 @@ double
|
|
541
506
|
rm_fuzz_to_dbl(VALUE fuzz_arg)
|
542
507
|
{
|
543
508
|
double fuzz;
|
544
|
-
char *
|
545
|
-
int not_num;
|
546
|
-
|
547
|
-
// Try to convert the argument to a number. If failure, sets not_num to non-zero.
|
548
|
-
(void) rb_protect(arg_is_number, fuzz_arg, ¬_num);
|
509
|
+
char *end;
|
549
510
|
|
550
|
-
if (
|
511
|
+
if (!rm_check_num2dbl(fuzz_arg))
|
551
512
|
{
|
513
|
+
char *fuzz_str;
|
514
|
+
|
552
515
|
// Convert to string, issue error message if failure.
|
553
516
|
fuzz_arg = rb_rescue(rb_str_to_str, fuzz_arg, rescue_not_str, fuzz_arg);
|
554
|
-
fuzz_str =
|
517
|
+
fuzz_str = StringValueCStr(fuzz_arg);
|
555
518
|
errno = 0;
|
556
519
|
fuzz = strtod(fuzz_str, &end);
|
557
520
|
if (errno == ERANGE)
|
@@ -606,11 +569,9 @@ rm_app2quantum(VALUE obj)
|
|
606
569
|
|
607
570
|
if (TYPE(obj) == T_FLOAT)
|
608
571
|
{
|
609
|
-
v =
|
572
|
+
v = rb_Integer(obj);
|
610
573
|
}
|
611
574
|
|
612
|
-
RB_GC_GUARD(v);
|
613
|
-
|
614
575
|
return NUM2QUANTUM(v);
|
615
576
|
}
|
616
577
|
|
@@ -626,7 +587,18 @@ rm_app2quantum(VALUE obj)
|
|
626
587
|
Image *
|
627
588
|
rm_acquire_image(ImageInfo *info)
|
628
589
|
{
|
590
|
+
#if defined(IMAGEMAGICK_7)
|
591
|
+
Image *new_image;
|
592
|
+
ExceptionInfo *exception;
|
593
|
+
|
594
|
+
exception = AcquireExceptionInfo();
|
595
|
+
new_image = AcquireImage(info, exception);
|
596
|
+
CHECK_EXCEPTION();
|
597
|
+
DestroyExceptionInfo(exception);
|
598
|
+
return new_image;
|
599
|
+
#else
|
629
600
|
return AcquireImage(info);
|
601
|
+
#endif
|
630
602
|
}
|
631
603
|
|
632
604
|
|
@@ -660,14 +632,21 @@ rm_cur_image(VALUE img)
|
|
660
632
|
VALUE
|
661
633
|
rm_pixelcolor_to_color_name(Image *image, PixelColor *color)
|
662
634
|
{
|
635
|
+
PixelColor pp;
|
663
636
|
char name[MaxTextExtent];
|
664
637
|
ExceptionInfo *exception;
|
665
638
|
|
666
639
|
exception = AcquireExceptionInfo();
|
667
640
|
|
668
|
-
|
669
|
-
|
670
|
-
|
641
|
+
pp = *color;
|
642
|
+
#if defined(IMAGEMAGICK_7)
|
643
|
+
pp.depth = MAGICKCORE_QUANTUM_DEPTH;
|
644
|
+
pp.colorspace = image->colorspace;
|
645
|
+
#endif
|
646
|
+
|
647
|
+
QueryColorname(image, &pp, X11Compliance, name, exception);
|
648
|
+
CHECK_EXCEPTION();
|
649
|
+
DestroyExceptionInfo(exception);
|
671
650
|
|
672
651
|
return rb_str_new2(name);
|
673
652
|
}
|
@@ -701,9 +680,14 @@ rm_pixelcolor_to_color_name_info(Info *info, PixelColor *color)
|
|
701
680
|
rb_raise(rb_eNoMemError, "not enough memory to continue.");
|
702
681
|
}
|
703
682
|
|
683
|
+
#if defined(IMAGEMAGICK_7)
|
684
|
+
image->alpha_trait = UndefinedPixelTrait;
|
685
|
+
#else
|
704
686
|
image->matte = MagickFalse;
|
687
|
+
#endif
|
688
|
+
|
705
689
|
color_name = rm_pixelcolor_to_color_name(image, color);
|
706
|
-
|
690
|
+
DestroyImage(image);
|
707
691
|
|
708
692
|
return color_name;
|
709
693
|
}
|
@@ -719,7 +703,11 @@ rm_pixelcolor_to_color_name_info(Info *info, PixelColor *color)
|
|
719
703
|
void
|
720
704
|
rm_init_magickpixel(const Image *image, MagickPixel *pp)
|
721
705
|
{
|
706
|
+
#if defined(IMAGEMAGICK_7)
|
707
|
+
GetPixelInfo(image, pp);
|
708
|
+
#else
|
722
709
|
GetMagickPixelPacket(image, pp);
|
710
|
+
#endif
|
723
711
|
}
|
724
712
|
|
725
713
|
/**
|
@@ -736,10 +724,15 @@ rm_set_magickpixel(MagickPixel *pp, const char *color)
|
|
736
724
|
ExceptionInfo *exception;
|
737
725
|
|
738
726
|
exception = AcquireExceptionInfo();
|
739
|
-
|
727
|
+
|
728
|
+
#if defined(IMAGEMAGICK_7)
|
729
|
+
QueryColorCompliance(color, AllCompliance, pp, exception);
|
730
|
+
#else
|
731
|
+
QueryMagickColor(color, pp, exception);
|
732
|
+
#endif
|
740
733
|
// This exception is ignored because the color comes from places where we control
|
741
734
|
// the value and it is very unlikely that an exception will be thrown.
|
742
|
-
|
735
|
+
DestroyExceptionInfo(exception);
|
743
736
|
}
|
744
737
|
|
745
738
|
/**
|
@@ -753,10 +746,11 @@ rm_set_magickpixel(MagickPixel *pp, const char *color)
|
|
753
746
|
*
|
754
747
|
* @param image the image
|
755
748
|
* @param temp_name the temporary name to use
|
749
|
+
* @param temp_name_l the length of temp_name
|
756
750
|
* @return the "filename" of the registered image
|
757
751
|
*/
|
758
752
|
void
|
759
|
-
rm_write_temp_image(Image *image, char *temp_name)
|
753
|
+
rm_write_temp_image(Image *image, char *temp_name, size_t temp_name_l)
|
760
754
|
{
|
761
755
|
|
762
756
|
#define TMPNAM_CLASS_VAR "@@_tmpnam_"
|
@@ -783,11 +777,11 @@ rm_write_temp_image(Image *image, char *temp_name)
|
|
783
777
|
|
784
778
|
id += 1;
|
785
779
|
rb_cv_set(Module_Magick, TMPNAM_CLASS_VAR, INT2FIX(id));
|
786
|
-
|
780
|
+
snprintf(temp_name, temp_name_l, "mpri:%d", id);
|
787
781
|
|
788
782
|
// Omit "mpri:" from filename to form the key
|
789
783
|
okay = SetImageRegistry(ImageRegistryType, temp_name+5, image, exception);
|
790
|
-
CHECK_EXCEPTION()
|
784
|
+
CHECK_EXCEPTION();
|
791
785
|
DestroyExceptionInfo(exception);
|
792
786
|
if (!okay)
|
793
787
|
{
|
@@ -858,28 +852,40 @@ rm_magick_error(const char *msg)
|
|
858
852
|
mesg = rb_str_new2(msg);
|
859
853
|
|
860
854
|
exc = rb_funcall(Class_ImageMagickError, rm_ID_new, 2, mesg, Qnil);
|
861
|
-
|
855
|
+
rb_funcall(rb_cObject, rb_intern("raise"), 1, exc);
|
862
856
|
|
863
857
|
RB_GC_GUARD(exc);
|
864
858
|
RB_GC_GUARD(mesg);
|
865
859
|
}
|
866
860
|
|
867
|
-
|
861
|
+
#if defined(IMAGEMAGICK_7)
|
868
862
|
/**
|
869
|
-
*
|
870
|
-
* \@magick_location instance variable.
|
863
|
+
* Sets the alpha channel of a pixel color
|
871
864
|
*
|
872
|
-
* Ruby usage
|
873
|
-
* - @verbatim ImageMagickError#initialize(msg) @endverbatim
|
874
|
-
* - @verbatim ImageMagickError#initialize(msg, loc) @endverbatim
|
865
|
+
* No Ruby usage (internal function)
|
875
866
|
*
|
876
|
-
*
|
877
|
-
*
|
867
|
+
* @param pixel the Pixel
|
868
|
+
* @param value the value
|
869
|
+
*/
|
870
|
+
void
|
871
|
+
rm_set_pixelinfo_alpha(PixelInfo *pixel, const MagickRealType value)
|
872
|
+
{
|
873
|
+
pixel->alpha = value;
|
874
|
+
if (value != (MagickRealType) OpaqueAlpha)
|
875
|
+
{
|
876
|
+
pixel->alpha_trait = BlendPixelTrait;
|
877
|
+
}
|
878
|
+
}
|
879
|
+
#endif
|
880
|
+
|
881
|
+
/**
|
882
|
+
* Initialize a new ImageMagickError object - store the "loc" string in the
|
883
|
+
* magick_location instance variable.
|
878
884
|
*
|
879
|
-
* @
|
880
|
-
*
|
881
|
-
*
|
882
|
-
*
|
885
|
+
* @overload initialize(msg, loc = nil)
|
886
|
+
* @param msg [String] the exception message
|
887
|
+
* @param loc [String] the location stored in the magick_location instance variable
|
888
|
+
* @return [Magick::ImageMagickError] self
|
883
889
|
*/
|
884
890
|
VALUE
|
885
891
|
ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
@@ -901,8 +907,8 @@ ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
|
901
907
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
|
902
908
|
}
|
903
909
|
|
904
|
-
|
905
|
-
|
910
|
+
rb_call_super(super_argc, (const VALUE *)super_argv);
|
911
|
+
rb_iv_set(self, "@"MAGICK_LOC, extra);
|
906
912
|
|
907
913
|
RB_GC_GUARD(extra);
|
908
914
|
|
@@ -922,7 +928,18 @@ ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
|
922
928
|
const char *
|
923
929
|
rm_get_property(const Image *img, const char *property)
|
924
930
|
{
|
931
|
+
#if defined(IMAGEMAGICK_7)
|
932
|
+
const char *result;
|
933
|
+
ExceptionInfo *exception;
|
934
|
+
|
935
|
+
exception = AcquireExceptionInfo();
|
936
|
+
result = GetImageProperty(img, property, exception);
|
937
|
+
CHECK_EXCEPTION();
|
938
|
+
DestroyExceptionInfo(exception);
|
939
|
+
return result;
|
940
|
+
#else
|
925
941
|
return GetImageProperty(img, property);
|
942
|
+
#endif
|
926
943
|
}
|
927
944
|
|
928
945
|
|
@@ -932,14 +949,25 @@ rm_get_property(const Image *img, const char *property)
|
|
932
949
|
* No Ruby usage (internal function)
|
933
950
|
*
|
934
951
|
* @param image the image
|
935
|
-
* @param property the property name
|
952
|
+
* @param property the property name
|
936
953
|
* @param value the property value
|
937
954
|
* @return true if successful, otherwise false
|
938
955
|
*/
|
939
956
|
MagickBooleanType
|
940
957
|
rm_set_property(Image *image, const char *property, const char *value)
|
941
958
|
{
|
959
|
+
#if defined(IMAGEMAGICK_7)
|
960
|
+
ExceptionInfo *exception;
|
961
|
+
MagickBooleanType okay;
|
962
|
+
|
963
|
+
exception = AcquireExceptionInfo();
|
964
|
+
okay = SetImageProperty(image, property, value, exception);
|
965
|
+
CHECK_EXCEPTION();
|
966
|
+
DestroyExceptionInfo(exception);
|
967
|
+
return okay;
|
968
|
+
#else
|
942
969
|
return SetImageProperty(image, property, value);
|
970
|
+
#endif
|
943
971
|
}
|
944
972
|
|
945
973
|
|
@@ -954,16 +982,17 @@ rm_set_property(Image *image, const char *property, const char *value)
|
|
954
982
|
*/
|
955
983
|
void rm_set_user_artifact(Image *images, Info *info)
|
956
984
|
{
|
957
|
-
Image *image;
|
958
985
|
const char *value;
|
959
986
|
|
960
987
|
value = GetImageOption(info, "user");
|
961
988
|
if (value)
|
962
989
|
{
|
990
|
+
Image *image;
|
991
|
+
|
963
992
|
image = GetFirstImageInList(images);
|
964
993
|
while (image)
|
965
994
|
{
|
966
|
-
|
995
|
+
SetImageArtifact(image, "user", value);
|
967
996
|
image = GetNextImageInList(image);
|
968
997
|
}
|
969
998
|
}
|
@@ -995,7 +1024,16 @@ rm_get_optional_arguments(VALUE img)
|
|
995
1024
|
optional_method_arguments = rb_const_get_from(Module_Magick, rb_intern("OptionalMethodArguments"));
|
996
1025
|
argv[0] = img;
|
997
1026
|
opt_args = rb_class_new_instance(1, argv, optional_method_arguments);
|
998
|
-
|
1027
|
+
|
1028
|
+
if (rb_proc_arity(rb_block_proc()) == 0)
|
1029
|
+
{
|
1030
|
+
rb_warn("passing a block without an image argument is deprecated");
|
1031
|
+
rb_obj_instance_eval(0, NULL, opt_args);
|
1032
|
+
}
|
1033
|
+
else
|
1034
|
+
{
|
1035
|
+
rb_yield(opt_args);
|
1036
|
+
}
|
999
1037
|
}
|
1000
1038
|
|
1001
1039
|
RB_GC_GUARD(optional_method_arguments);
|
@@ -1016,17 +1054,18 @@ rm_get_optional_arguments(VALUE img)
|
|
1016
1054
|
static void copy_options(Image *image, Info *info)
|
1017
1055
|
{
|
1018
1056
|
char property[MaxTextExtent];
|
1019
|
-
const char *
|
1057
|
+
const char *option;
|
1020
1058
|
|
1021
1059
|
ResetImageOptionIterator(info);
|
1022
1060
|
for (option = GetNextImageOption(info); option; option = GetNextImageOption(info))
|
1023
1061
|
{
|
1024
|
-
|
1062
|
+
const char *value;
|
1063
|
+
|
1064
|
+
value = GetImageOption(info, option);
|
1025
1065
|
if (value)
|
1026
1066
|
{
|
1027
|
-
|
1028
|
-
property
|
1029
|
-
(void) SetImageArtifact(image, property, value);
|
1067
|
+
strlcpy(property, value, sizeof(property));
|
1068
|
+
SetImageArtifact(image, property, value);
|
1030
1069
|
}
|
1031
1070
|
}
|
1032
1071
|
}
|
@@ -1046,16 +1085,19 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1046
1085
|
MagickStatusType flags;
|
1047
1086
|
GeometryInfo geometry_info;
|
1048
1087
|
const char *option;
|
1088
|
+
#if defined(IMAGEMAGICK_7)
|
1089
|
+
ExceptionInfo *exception;
|
1090
|
+
#endif
|
1049
1091
|
|
1050
1092
|
// The option strings will be set only when their attribute values were
|
1051
1093
|
// set in the optional argument block.
|
1052
|
-
option = GetImageOption(info,"background");
|
1094
|
+
option = GetImageOption(info, "background");
|
1053
1095
|
if (option)
|
1054
1096
|
{
|
1055
1097
|
image->background_color = info->background_color;
|
1056
1098
|
}
|
1057
1099
|
|
1058
|
-
option = GetImageOption(info,"bordercolor");
|
1100
|
+
option = GetImageOption(info, "bordercolor");
|
1059
1101
|
if (option)
|
1060
1102
|
{
|
1061
1103
|
image->border_color = info->border_color;
|
@@ -1063,7 +1105,16 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1063
1105
|
|
1064
1106
|
if (info->colorspace != UndefinedColorspace)
|
1065
1107
|
{
|
1108
|
+
#if defined(IMAGEMAGICK_7)
|
1109
|
+
exception = AcquireExceptionInfo();
|
1110
|
+
SetImageColorspace(image, info->colorspace, exception);
|
1111
|
+
// We should not throw an exception in this method because we will
|
1112
|
+
// leak memory in the place where this method is called. And that is
|
1113
|
+
// why the exception is being ignored here.
|
1114
|
+
DestroyExceptionInfo(exception);
|
1115
|
+
#else
|
1066
1116
|
SetImageColorspace(image, info->colorspace);
|
1117
|
+
#endif
|
1067
1118
|
}
|
1068
1119
|
|
1069
1120
|
if (info->compression != UndefinedCompression)
|
@@ -1080,11 +1131,20 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1080
1131
|
if (info->density)
|
1081
1132
|
{
|
1082
1133
|
flags = ParseGeometry(info->density, &geometry_info);
|
1134
|
+
#if defined(IMAGEMAGICK_7)
|
1135
|
+
image->resolution.x = geometry_info.rho;
|
1136
|
+
image->resolution.y = geometry_info.sigma;
|
1137
|
+
#else
|
1083
1138
|
image->x_resolution = geometry_info.rho;
|
1084
1139
|
image->y_resolution = geometry_info.sigma;
|
1140
|
+
#endif
|
1085
1141
|
if ((flags & SigmaValue) == 0)
|
1086
1142
|
{
|
1143
|
+
#if defined(IMAGEMAGICK_7)
|
1144
|
+
image->resolution.y = image->resolution.x;
|
1145
|
+
#else
|
1087
1146
|
image->y_resolution = image->x_resolution;
|
1147
|
+
#endif
|
1088
1148
|
}
|
1089
1149
|
}
|
1090
1150
|
|
@@ -1120,7 +1180,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1120
1180
|
image->interlace = info->interlace;
|
1121
1181
|
}
|
1122
1182
|
|
1123
|
-
option = GetImageOption(info,"mattecolor");
|
1183
|
+
option = GetImageOption(info, "mattecolor");
|
1124
1184
|
if (option)
|
1125
1185
|
{
|
1126
1186
|
image->matte_color = info->matte_color;
|
@@ -1133,7 +1193,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1133
1193
|
|
1134
1194
|
if (info->page)
|
1135
1195
|
{
|
1136
|
-
|
1196
|
+
ParseAbsoluteGeometry(info->page, &image->page);
|
1137
1197
|
}
|
1138
1198
|
|
1139
1199
|
if (info->quality != 0UL)
|
@@ -1150,7 +1210,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1150
1210
|
option = GetImageOption(info, "tile-offset");
|
1151
1211
|
if (option)
|
1152
1212
|
{
|
1153
|
-
|
1213
|
+
ParseAbsoluteGeometry(option, &image->tile_offset);
|
1154
1214
|
}
|
1155
1215
|
|
1156
1216
|
option = GetImageOption(info, "transparent");
|
@@ -1174,8 +1234,13 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1174
1234
|
{
|
1175
1235
|
if (info->units == PixelsPerCentimeterResolution)
|
1176
1236
|
{
|
1237
|
+
#if defined(IMAGEMAGICK_7)
|
1238
|
+
image->resolution.x /= 2.54;
|
1239
|
+
image->resolution.y /= 2.54;
|
1240
|
+
#else
|
1177
1241
|
image->x_resolution /= 2.54;
|
1178
1242
|
image->y_resolution /= 2.54;
|
1243
|
+
#endif
|
1179
1244
|
}
|
1180
1245
|
break;
|
1181
1246
|
}
|
@@ -1183,8 +1248,13 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1183
1248
|
{
|
1184
1249
|
if (info->units == PixelsPerInchResolution)
|
1185
1250
|
{
|
1251
|
+
#if defined(IMAGEMAGICK_7)
|
1252
|
+
image->resolution.x *= 2.54;
|
1253
|
+
image->resolution.y *= 2.54;
|
1254
|
+
#else
|
1186
1255
|
image->x_resolution *= 2.54;
|
1187
1256
|
image->y_resolution *= 2.54;
|
1257
|
+
#endif
|
1188
1258
|
}
|
1189
1259
|
break;
|
1190
1260
|
}
|
@@ -1219,8 +1289,16 @@ rm_exif_by_entry(Image *image)
|
|
1219
1289
|
char *str;
|
1220
1290
|
size_t len = 0, property_l, value_l;
|
1221
1291
|
VALUE v;
|
1292
|
+
#if defined(IMAGEMAGICK_7)
|
1293
|
+
ExceptionInfo *exception;
|
1294
|
+
|
1295
|
+
exception = AcquireExceptionInfo();
|
1296
|
+
GetImageProperty(image, "exif:*", exception);
|
1297
|
+
CHECK_EXCEPTION();
|
1298
|
+
#else
|
1299
|
+
GetImageProperty(image, "exif:*");
|
1300
|
+
#endif
|
1222
1301
|
|
1223
|
-
(void) GetImageProperty(image, "exif:*");
|
1224
1302
|
ResetImagePropertyIterator(image);
|
1225
1303
|
property = GetNextImageProperty(image);
|
1226
1304
|
|
@@ -1228,7 +1306,7 @@ rm_exif_by_entry(Image *image)
|
|
1228
1306
|
while (property)
|
1229
1307
|
{
|
1230
1308
|
// ignore properties that don't start with "exif:"
|
1231
|
-
property_l =
|
1309
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1232
1310
|
if (property_l > 5 && rm_strncasecmp(property, "exif:", 5) == 0)
|
1233
1311
|
{
|
1234
1312
|
if (len > 0)
|
@@ -1236,11 +1314,16 @@ rm_exif_by_entry(Image *image)
|
|
1236
1314
|
len += 1; // there will be a \n between property=value entries
|
1237
1315
|
}
|
1238
1316
|
len += property_l - 5;
|
1239
|
-
|
1317
|
+
#if defined(IMAGEMAGICK_7)
|
1318
|
+
value = GetImageProperty(image, property, exception);
|
1319
|
+
CHECK_EXCEPTION();
|
1320
|
+
#else
|
1321
|
+
value = GetImageProperty(image, property);
|
1322
|
+
#endif
|
1240
1323
|
if (value)
|
1241
1324
|
{
|
1242
1325
|
// add 1 for the = between property and value
|
1243
|
-
len += 1 +
|
1326
|
+
len += 1 + rm_strnlen_s(value, MaxTextExtent);
|
1244
1327
|
}
|
1245
1328
|
}
|
1246
1329
|
property = GetNextImageProperty(image);
|
@@ -1248,8 +1331,12 @@ rm_exif_by_entry(Image *image)
|
|
1248
1331
|
|
1249
1332
|
if (len == 0)
|
1250
1333
|
{
|
1334
|
+
#if defined(IMAGEMAGICK_7)
|
1335
|
+
DestroyExceptionInfo(exception);
|
1336
|
+
#endif
|
1251
1337
|
return Qnil;
|
1252
1338
|
}
|
1339
|
+
|
1253
1340
|
str = xmalloc(len);
|
1254
1341
|
len = 0;
|
1255
1342
|
|
@@ -1259,7 +1346,7 @@ rm_exif_by_entry(Image *image)
|
|
1259
1346
|
|
1260
1347
|
while (property)
|
1261
1348
|
{
|
1262
|
-
property_l =
|
1349
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1263
1350
|
if (property_l > 5 && rm_strncasecmp(property, "exif:", 5) == 0)
|
1264
1351
|
{
|
1265
1352
|
if (len > 0)
|
@@ -1268,10 +1355,19 @@ rm_exif_by_entry(Image *image)
|
|
1268
1355
|
}
|
1269
1356
|
memcpy(str+len, property+5, property_l-5);
|
1270
1357
|
len += property_l - 5;
|
1271
|
-
|
1358
|
+
#if defined(IMAGEMAGICK_7)
|
1359
|
+
value = GetImageProperty(image, property, exception);
|
1360
|
+
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
1361
|
+
{
|
1362
|
+
xfree(str);
|
1363
|
+
rm_raise_exception(exception);
|
1364
|
+
}
|
1365
|
+
#else
|
1366
|
+
value = GetImageProperty(image, property);
|
1367
|
+
#endif
|
1272
1368
|
if (value)
|
1273
1369
|
{
|
1274
|
-
value_l =
|
1370
|
+
value_l = rm_strnlen_s(value, MaxTextExtent);
|
1275
1371
|
str[len++] = '=';
|
1276
1372
|
memcpy(str+len, value, value_l);
|
1277
1373
|
len += value_l;
|
@@ -1280,6 +1376,10 @@ rm_exif_by_entry(Image *image)
|
|
1280
1376
|
property = GetNextImageProperty(image);
|
1281
1377
|
}
|
1282
1378
|
|
1379
|
+
#if defined(IMAGEMAGICK_7)
|
1380
|
+
DestroyExceptionInfo(exception);
|
1381
|
+
#endif
|
1382
|
+
|
1283
1383
|
v = rb_str_new(str, len);
|
1284
1384
|
xfree(str);
|
1285
1385
|
|
@@ -1308,8 +1408,15 @@ rm_exif_by_number(Image *image)
|
|
1308
1408
|
char *str;
|
1309
1409
|
size_t len = 0, property_l, value_l;
|
1310
1410
|
VALUE v;
|
1411
|
+
#if defined(IMAGEMAGICK_7)
|
1412
|
+
ExceptionInfo *exception;
|
1311
1413
|
|
1312
|
-
|
1414
|
+
exception = AcquireExceptionInfo();
|
1415
|
+
GetImageProperty(image, "exif:!", exception);
|
1416
|
+
CHECK_EXCEPTION();
|
1417
|
+
#else
|
1418
|
+
GetImageProperty(image, "exif:!");
|
1419
|
+
#endif
|
1313
1420
|
ResetImagePropertyIterator(image);
|
1314
1421
|
property = GetNextImageProperty(image);
|
1315
1422
|
|
@@ -1317,7 +1424,7 @@ rm_exif_by_number(Image *image)
|
|
1317
1424
|
while (property)
|
1318
1425
|
{
|
1319
1426
|
// ignore properties that don't start with "#"
|
1320
|
-
property_l =
|
1427
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1321
1428
|
if (property_l > 1 && property[0] == '#')
|
1322
1429
|
{
|
1323
1430
|
if (len > 0)
|
@@ -1325,11 +1432,16 @@ rm_exif_by_number(Image *image)
|
|
1325
1432
|
len += 1; // there will be a \n between property=value entries
|
1326
1433
|
}
|
1327
1434
|
len += property_l;
|
1328
|
-
|
1435
|
+
#if defined(IMAGEMAGICK_7)
|
1436
|
+
value = GetImageProperty(image, property, exception);
|
1437
|
+
CHECK_EXCEPTION();
|
1438
|
+
#else
|
1439
|
+
value = GetImageProperty(image, property);
|
1440
|
+
#endif
|
1329
1441
|
if (value)
|
1330
1442
|
{
|
1331
1443
|
// add 1 for the = between property and value
|
1332
|
-
len += 1 +
|
1444
|
+
len += 1 + rm_strnlen_s(value, MaxTextExtent);
|
1333
1445
|
}
|
1334
1446
|
}
|
1335
1447
|
property = GetNextImageProperty(image);
|
@@ -1337,8 +1449,12 @@ rm_exif_by_number(Image *image)
|
|
1337
1449
|
|
1338
1450
|
if (len == 0)
|
1339
1451
|
{
|
1452
|
+
#if defined(IMAGEMAGICK_7)
|
1453
|
+
DestroyExceptionInfo(exception);
|
1454
|
+
#endif
|
1340
1455
|
return Qnil;
|
1341
1456
|
}
|
1457
|
+
|
1342
1458
|
str = xmalloc(len);
|
1343
1459
|
len = 0;
|
1344
1460
|
|
@@ -1348,7 +1464,7 @@ rm_exif_by_number(Image *image)
|
|
1348
1464
|
|
1349
1465
|
while (property)
|
1350
1466
|
{
|
1351
|
-
property_l =
|
1467
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1352
1468
|
if (property_l > 1 && property[0] == '#')
|
1353
1469
|
{
|
1354
1470
|
if (len > 0)
|
@@ -1357,10 +1473,19 @@ rm_exif_by_number(Image *image)
|
|
1357
1473
|
}
|
1358
1474
|
memcpy(str+len, property, property_l);
|
1359
1475
|
len += property_l;
|
1360
|
-
|
1476
|
+
#if defined(IMAGEMAGICK_7)
|
1477
|
+
value = GetImageProperty(image, property, exception);
|
1478
|
+
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
1479
|
+
{
|
1480
|
+
xfree(str);
|
1481
|
+
rm_raise_exception(exception);
|
1482
|
+
}
|
1483
|
+
#else
|
1484
|
+
value = GetImageProperty(image, property);
|
1485
|
+
#endif
|
1361
1486
|
if (value)
|
1362
1487
|
{
|
1363
|
-
value_l =
|
1488
|
+
value_l = rm_strnlen_s(value, MaxTextExtent);
|
1364
1489
|
str[len++] = '=';
|
1365
1490
|
memcpy(str+len, value, value_l);
|
1366
1491
|
len += value_l;
|
@@ -1369,6 +1494,10 @@ rm_exif_by_number(Image *image)
|
|
1369
1494
|
property = GetNextImageProperty(image);
|
1370
1495
|
}
|
1371
1496
|
|
1497
|
+
#if defined(IMAGEMAGICK_7)
|
1498
|
+
DestroyExceptionInfo(exception);
|
1499
|
+
#endif
|
1500
|
+
|
1372
1501
|
v = rb_str_new(str, len);
|
1373
1502
|
xfree(str);
|
1374
1503
|
|
@@ -1378,66 +1507,6 @@ rm_exif_by_number(Image *image)
|
|
1378
1507
|
}
|
1379
1508
|
|
1380
1509
|
|
1381
|
-
/**
|
1382
|
-
* Get the values from a Geometry object and return them in C variables.
|
1383
|
-
*
|
1384
|
-
* No Ruby usage (internal function)
|
1385
|
-
*
|
1386
|
-
* Notes:
|
1387
|
-
* - No return value: modifies x, y, width, height, and flag
|
1388
|
-
*
|
1389
|
-
* @param geom the Geometry object
|
1390
|
-
* @param x pointer to the x position of the start of the rectangle
|
1391
|
-
* @param y pointer to the y position of the start of the rectangle
|
1392
|
-
* @param width pointer to the width of the rectangle
|
1393
|
-
* @param height pointer to the height of the rectangle
|
1394
|
-
* @param flag pointer to the Geometry's flag
|
1395
|
-
*/
|
1396
|
-
void
|
1397
|
-
rm_get_geometry(
|
1398
|
-
VALUE geom,
|
1399
|
-
long *x,
|
1400
|
-
long *y,
|
1401
|
-
unsigned long *width,
|
1402
|
-
unsigned long *height,
|
1403
|
-
int *flag)
|
1404
|
-
{
|
1405
|
-
VALUE v;
|
1406
|
-
|
1407
|
-
v = rb_funcall(geom, rm_ID_x, 0);
|
1408
|
-
*x = NUM2LONG(v);
|
1409
|
-
v = rb_funcall(geom, rm_ID_y, 0);
|
1410
|
-
*y = NUM2LONG(v);
|
1411
|
-
v = rb_funcall(geom, rm_ID_width, 0);
|
1412
|
-
*width = NUM2ULONG(v);
|
1413
|
-
v = rb_funcall(geom, rm_ID_height, 0);
|
1414
|
-
*height = NUM2ULONG(v);
|
1415
|
-
|
1416
|
-
// Getting the flag field is a bit more difficult since it's
|
1417
|
-
// supposed to be an instance of the GeometryValue Enum class. We
|
1418
|
-
// may not know the VALUE for the GeometryValue class, and we
|
1419
|
-
// need to check that the flag field is an instance of that class.
|
1420
|
-
if (flag)
|
1421
|
-
{
|
1422
|
-
MagickEnum *magick_enum;
|
1423
|
-
|
1424
|
-
v = rb_funcall(geom, rm_ID_flag, 0);
|
1425
|
-
if (!Class_GeometryValue)
|
1426
|
-
{
|
1427
|
-
Class_GeometryValue = rb_const_get(Module_Magick, rm_ID_GeometryValue);
|
1428
|
-
}
|
1429
|
-
if (CLASS_OF(v) != Class_GeometryValue)
|
1430
|
-
{
|
1431
|
-
rb_raise(rb_eTypeError, "wrong enumeration type - expected %s, got %s"
|
1432
|
-
, rb_class2name(Class_GeometryValue),rb_class2name(CLASS_OF(v)));
|
1433
|
-
}
|
1434
|
-
Data_Get_Struct(v, MagickEnum, magick_enum);
|
1435
|
-
*flag = magick_enum->val;
|
1436
|
-
}
|
1437
|
-
|
1438
|
-
}
|
1439
|
-
|
1440
|
-
|
1441
1510
|
/**
|
1442
1511
|
* Clone an image, handle errors.
|
1443
1512
|
*
|
@@ -1463,7 +1532,7 @@ rm_clone_image(Image *image)
|
|
1463
1532
|
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
1464
1533
|
}
|
1465
1534
|
rm_check_exception(exception, clone, DestroyOnError);
|
1466
|
-
|
1535
|
+
DestroyExceptionInfo(exception);
|
1467
1536
|
|
1468
1537
|
return clone;
|
1469
1538
|
}
|
@@ -1494,14 +1563,15 @@ rm_progress_monitor(
|
|
1494
1563
|
VALUE rval;
|
1495
1564
|
VALUE method, offset, span;
|
1496
1565
|
|
1497
|
-
//
|
1498
|
-
|
1499
|
-
|
1500
|
-
// Check stack length manually instead of ruby_stack_check() for old Ruby.
|
1501
|
-
if (ruby_stack_length(NULL) > RUBY_VM_THREAD_MACHINE_STACK_SIZE_MIN)
|
1566
|
+
// Check running thread.
|
1567
|
+
if (rm_current_thread_id() != rm_main_thread_id)
|
1502
1568
|
{
|
1503
|
-
//
|
1504
|
-
//
|
1569
|
+
// ImageMagick might call back in a different thread than Ruby is running in.
|
1570
|
+
// If it is a different thread, it would not have a Ruby GVL and
|
1571
|
+
// it could not retrieve properly Ruby stack.
|
1572
|
+
|
1573
|
+
// Unfortunately, there is no API available to check if the current thread has a GVL,
|
1574
|
+
// so the thread id was checked in here.
|
1505
1575
|
return MagickTrue;
|
1506
1576
|
}
|
1507
1577
|
|
@@ -1546,11 +1616,12 @@ rm_split(Image *image)
|
|
1546
1616
|
}
|
1547
1617
|
while (image)
|
1548
1618
|
{
|
1549
|
-
|
1619
|
+
RemoveFirstImageFromList(&image);
|
1550
1620
|
}
|
1551
1621
|
}
|
1552
1622
|
|
1553
1623
|
|
1624
|
+
#if defined(IMAGEMAGICK_6)
|
1554
1625
|
/**
|
1555
1626
|
* If an ExceptionInfo struct in a list of images indicates a warning, issue a
|
1556
1627
|
* warning message. If an ExceptionInfo struct indicates an error, raise an
|
@@ -1598,8 +1669,9 @@ rm_check_image_exception(Image *imglist, ErrorRetention retention)
|
|
1598
1669
|
rm_check_exception(exception, imglist, retention);
|
1599
1670
|
}
|
1600
1671
|
|
1601
|
-
|
1672
|
+
DestroyExceptionInfo(exception);
|
1602
1673
|
}
|
1674
|
+
#endif
|
1603
1675
|
|
1604
1676
|
|
1605
1677
|
#define ERROR_MSG_SIZE 1024
|
@@ -1617,7 +1689,7 @@ static void
|
|
1617
1689
|
format_exception(const ExceptionType severity, const char *reason, const char *description, char *msg)
|
1618
1690
|
{
|
1619
1691
|
int len;
|
1620
|
-
memset(msg, 0,
|
1692
|
+
memset(msg, 0, ERROR_MSG_SIZE);
|
1621
1693
|
|
1622
1694
|
len = snprintf(msg, ERROR_MSG_SIZE, "%s%s%s",
|
1623
1695
|
GetLocaleExceptionMessage(severity, reason),
|
@@ -1746,7 +1818,7 @@ handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retent
|
|
1746
1818
|
{
|
1747
1819
|
if (retention == DestroyOnError)
|
1748
1820
|
{
|
1749
|
-
|
1821
|
+
DestroyImageList(imglist);
|
1750
1822
|
imglist = NULL;
|
1751
1823
|
}
|
1752
1824
|
else
|
@@ -1757,7 +1829,7 @@ handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retent
|
|
1757
1829
|
|
1758
1830
|
format_exception(exception->severity, exception->reason, exception->description, msg);
|
1759
1831
|
|
1760
|
-
|
1832
|
+
DestroyExceptionInfo(exception);
|
1761
1833
|
|
1762
1834
|
rm_magick_error(msg);
|
1763
1835
|
}
|
@@ -1801,7 +1873,7 @@ rm_should_raise_exception(ExceptionInfo *exception, const ExceptionRetention ret
|
|
1801
1873
|
|
1802
1874
|
if (retention == DestroyExceptionRetention)
|
1803
1875
|
{
|
1804
|
-
|
1876
|
+
DestroyExceptionInfo(exception);
|
1805
1877
|
}
|
1806
1878
|
|
1807
1879
|
return MagickFalse;
|
@@ -1825,8 +1897,24 @@ rm_raise_exception(ExceptionInfo *exception)
|
|
1825
1897
|
|
1826
1898
|
format_exception(exception->severity, exception->reason, exception->description, msg);
|
1827
1899
|
|
1828
|
-
|
1900
|
+
DestroyExceptionInfo(exception);
|
1829
1901
|
|
1830
1902
|
rm_magick_error(msg);
|
1831
1903
|
}
|
1832
1904
|
|
1905
|
+
/**
|
1906
|
+
* Get current thread id.
|
1907
|
+
*
|
1908
|
+
* No Ruby usage (internal function)
|
1909
|
+
*
|
1910
|
+
* @return thread id
|
1911
|
+
*/
|
1912
|
+
unsigned long long
|
1913
|
+
rm_current_thread_id()
|
1914
|
+
{
|
1915
|
+
#if defined(_WIN32)
|
1916
|
+
return (unsigned long long)GetCurrentThreadId();
|
1917
|
+
#else
|
1918
|
+
return (unsigned long long)pthread_self();
|
1919
|
+
#endif
|
1920
|
+
}
|