rmagick 2.4.0 → 2.5.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.

@@ -1,7 +1,7 @@
1
1
  require "mkmf"
2
2
  require "date"
3
3
 
4
- RMAGICK_VERS = "2.4.0"
4
+ RMAGICK_VERS = "2.5.0"
5
5
  MIN_RUBY_VERS = "1.8.2"
6
6
  MIN_RUBY_VERS_NO = MIN_RUBY_VERS.tr(".","").to_i
7
7
  MIN_IM_VERS = "6.3.0"
@@ -173,6 +173,7 @@ have_func("snprintf", headers)
173
173
  "ResetImagePage", # 6.3.3
174
174
  "ResizeQuantumMemory", # 6.3.5-9
175
175
  "SetImageAlphaChannel", # 6.3.6-9
176
+ "SetImageMask", # 6.3.1
176
177
  "SetImageProperty", # 6.3.1
177
178
  "SetImageRegistry", # 6.3.4-?
178
179
  "SyncImageProfiles", # 6.3.2
@@ -1,4 +1,4 @@
1
- /* $Id: rmagick.h,v 1.234 2008/06/02 22:47:37 rmagick Exp $ */
1
+ /* $Id: rmagick.h,v 1.235 2008/06/06 00:24:14 rmagick Exp $ */
2
2
  /*=============================================================================
3
3
  | Copyright (C) 2008 by Timothy P. Hunter
4
4
  | Name: rmagick.h
@@ -773,6 +773,7 @@ extern VALUE Image_adaptive_resize(int, VALUE *, VALUE);
773
773
  extern VALUE Image_adaptive_sharpen(int, VALUE *, VALUE);
774
774
  extern VALUE Image_adaptive_sharpen_channel(int, VALUE *, VALUE);
775
775
  extern VALUE Image_adaptive_threshold(int, VALUE *, VALUE);
776
+ extern VALUE Image_add_compose_mask(VALUE, VALUE);
776
777
  extern VALUE Image_add_noise(VALUE, VALUE);
777
778
  extern VALUE Image_add_noise_channel(int, VALUE *, VALUE);
778
779
  extern VALUE Image_add_profile(VALUE, VALUE);
@@ -826,6 +827,7 @@ extern VALUE Image_crop_bang(int, VALUE *, VALUE);
826
827
  extern VALUE Image_cycle_colormap(VALUE, VALUE);
827
828
  extern VALUE Image_decipher(VALUE, VALUE);
828
829
  extern VALUE Image_delete_profile(VALUE, VALUE);
830
+ extern VALUE Image_delete_compose_mask(VALUE);
829
831
  extern VALUE Image_despeckle(VALUE);
830
832
  extern VALUE Image_destroy_bang(VALUE);
831
833
  extern VALUE Image_destroyed_q(VALUE);
@@ -1,4 +1,4 @@
1
- /* $Id: rmimage.c,v 1.295 2008/06/02 22:47:37 rmagick Exp $ */
1
+ /* $Id: rmimage.c,v 1.297 2008/06/06 22:39:51 rmagick Exp $ */
2
2
  /*============================================================================\
3
3
  | Copyright (C) 2008 by Timothy P. Hunter
4
4
  | Name: rmimage.c
@@ -265,6 +265,53 @@ Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
265
265
  return rm_image_new(new_image);
266
266
  }
267
267
 
268
+
269
+ /*
270
+ Method: Image#add_compose_mask(mask)
271
+ Purpose: Set the image composite mask
272
+ Ref: SetImageMask
273
+ Notes: Returns self
274
+ See also: Image#mask(), #delete_compose_mask()
275
+ */
276
+ VALUE
277
+ Image_add_compose_mask(VALUE self, VALUE mask)
278
+ {
279
+ Image *image;
280
+ Image *mask_image = NULL;
281
+
282
+ image = rm_check_frozen(self);
283
+ mask_image = rm_check_destroyed(mask);
284
+ if (image->columns != mask_image->columns || image->rows != mask_image->rows)
285
+ {
286
+ rb_raise(rb_eArgError, "mask must be the same size as image");
287
+ }
288
+
289
+ // Delete any previously-existing mask image.
290
+ // Store a clone of the new mask image.
291
+ #if defined(HAVE_SETIMAGEMASK)
292
+ (void) SetImageMask(image, mask_image);
293
+ (void) NegateImage(image->mask, MagickFalse);
294
+ #else
295
+ if (image->clip_mask)
296
+ {
297
+ image->clip_mask = DestroyImage(image->clip_mask);
298
+ }
299
+ image->clip_mask = NewImageList();
300
+ if (SetImageStorageClass(image, DirectClass) == MagickFalse)
301
+ {
302
+ rm_magick_error("SetImageStorageClass failed", NULL);
303
+ }
304
+ image->clip_mask = rm_clone_image(mask_image);
305
+ (void) NegateImage(image->clip_mask, MagickFalse);
306
+ #endif
307
+
308
+ // Since both Set and GetImageMask clone the mask image I don't see any
309
+ // way to negate the mask without referencing it directly. Sigh.
310
+
311
+ return self;
312
+ }
313
+
314
+
268
315
  /*
269
316
  Method: Image#add_noise(noise_type)
270
317
  Purpose: add random noise to a copy of the image
@@ -3314,6 +3361,36 @@ Image_decipher(VALUE self, VALUE passphrase)
3314
3361
  DEF_ATTR_ACCESSOR(Image, delay, ulong)
3315
3362
 
3316
3363
 
3364
+ /*
3365
+ Method: Image#delete_compose_mask()
3366
+ Purpose: Delete the image composite mask
3367
+ Ref: SetImageMask
3368
+ Notes: Returns self
3369
+ See also: #add_compose_mask()
3370
+ */
3371
+ VALUE
3372
+ Image_delete_compose_mask(VALUE self)
3373
+ {
3374
+ Image *image = rm_check_frozen(self);
3375
+
3376
+ // Store a clone of the mask image
3377
+ #if defined(HAVE_SETIMAGEMASK)
3378
+ {
3379
+ (void) SetImageMask(image, NULL);
3380
+ rm_check_image_exception(image, RetainOnError);
3381
+ }
3382
+ #else
3383
+ if (image->clip_mask)
3384
+ {
3385
+ image->clip_mask = DestroyImage(image->clip_mask);
3386
+ }
3387
+ image->clip_mask = NewImageList();
3388
+ #endif
3389
+
3390
+ return self;
3391
+ }
3392
+
3393
+
3317
3394
  /*
3318
3395
  Method: Image#delete_profile(name)
3319
3396
  Purpose: call ProfileImage
@@ -1,4 +1,4 @@
1
- /* $Id: rmmain.c,v 1.250 2008/06/02 22:47:37 rmagick Exp $ */
1
+ /* $Id: rmmain.c,v 1.251 2008/06/06 00:24:14 rmagick Exp $ */
2
2
  /*============================================================================\
3
3
  | Copyright (C) 2008 by Timothy P. Hunter
4
4
  | Name: rmmain.c
@@ -474,6 +474,7 @@ Init_RMagick2(void)
474
474
  rb_define_method(Class_Image, "adaptive_sharpen", Image_adaptive_sharpen, -1);
475
475
  rb_define_method(Class_Image, "adaptive_sharpen_channel", Image_adaptive_sharpen_channel, -1);
476
476
  rb_define_method(Class_Image, "adaptive_threshold", Image_adaptive_threshold, -1);
477
+ rb_define_method(Class_Image, "add_compose_mask", Image_add_compose_mask, 1);
477
478
  rb_define_method(Class_Image, "add_noise", Image_add_noise, 1);
478
479
  rb_define_method(Class_Image, "add_noise_channel", Image_add_noise_channel, -1);
479
480
  rb_define_method(Class_Image, "add_profile", Image_add_profile, 1);
@@ -526,6 +527,7 @@ Init_RMagick2(void)
526
527
  rb_define_method(Class_Image, "crop!", Image_crop_bang, -1);
527
528
  rb_define_method(Class_Image, "cycle_colormap", Image_cycle_colormap, 1);
528
529
  rb_define_method(Class_Image, "decipher", Image_decipher, 1);
530
+ rb_define_method(Class_Image, "delete_compose_mask", Image_delete_compose_mask, 0);
529
531
  rb_define_method(Class_Image, "delete_profile", Image_delete_profile, 1);
530
532
  rb_define_method(Class_Image, "despeckle", Image_despeckle, 0);
531
533
  rb_define_method(Class_Image, "destroy!", Image_destroy_bang, 0);
@@ -1708,7 +1710,7 @@ static void version_constants(void)
1708
1710
  rb_define_const(Module_Magick, "Version", str);
1709
1711
 
1710
1712
  sprintf(long_version,
1711
- "This is %s ($Date: 2008/06/02 22:47:37 $) Copyright (C) 2008 by Timothy P. Hunter\n"
1713
+ "This is %s ($Date: 2008/06/06 00:24:14 $) Copyright (C) 2008 by Timothy P. Hunter\n"
1712
1714
  "Built with %s\n"
1713
1715
  "Built for %s\n"
1714
1716
  "Web page: http://rmagick.rubyforge.org\n"
@@ -1,4 +1,4 @@
1
- # $Id: RMagick.rb,v 1.69 2008/06/02 22:46:51 rmagick Exp $
1
+ # $Id: RMagick.rb,v 1.72 2008/06/08 13:41:39 rmagick Exp $
2
2
  #==============================================================================
3
3
  # Copyright (C) 2008 by Timothy P. Hunter
4
4
  # Name: RMagick.rb
@@ -37,18 +37,24 @@ AspectGeometry = GeometryValue.new(:AspectGeometry, 2).freeze
37
37
  LessGeometry = GeometryValue.new(:LessGeometry, 3).freeze
38
38
  GreaterGeometry = GeometryValue.new(:GreaterGeometry, 4).freeze
39
39
  AreaGeometry = GeometryValue.new(:AreaGeometry, 5).freeze
40
+ MinimumGeometry = GeometryValue.new(:MinimumGeometry, 6).freeze
40
41
 
41
42
  class Geometry
42
- FLAGS = ['', '%', '!', '<', '>', '@']
43
+ FLAGS = ['', '%', '!', '<', '>', '@', '^']
43
44
  RFLAGS = { '%' => PercentGeometry,
44
45
  '!' => AspectGeometry,
45
46
  '<' => LessGeometry,
46
47
  '>' => GreaterGeometry,
47
- '@' => AreaGeometry }
48
+ '@' => AreaGeometry,
49
+ '^' => MinimumGeometry }
48
50
 
49
51
  attr_accessor :width, :height, :x, :y, :flag
50
52
 
51
53
  def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil)
54
+ raise(ArgumentError, "width set to #{width.to_s}") if width.is_a? GeometryValue
55
+ raise(ArgumentError, "height set to #{height.to_s}") if height.is_a? GeometryValue
56
+ raise(ArgumentError, "x set to #{x.to_s}") if x.is_a? GeometryValue
57
+ raise(ArgumentError, "y set to #{y.to_s}") if y.is_a? GeometryValue
52
58
 
53
59
  # Support floating-point width and height arguments so Geometry
54
60
  # objects can be used to specify Image#density= arguments.
@@ -70,35 +76,57 @@ class Geometry
70
76
  @x = x.to_i
71
77
  @y = y.to_i
72
78
  @flag = flag
79
+
73
80
  end
74
81
 
75
82
  # Construct an object from a geometry string
76
- RE = /\A(\d*)(?:x(\d+))?([-+]\d+)?([-+]\d+)?([%!<>@]?)\Z/
83
+ W = /(\d+\.\d+%?)|(\d*%?)/
84
+ H = W
85
+ X = /(?:([-+]\d+))?/
86
+ Y = X
87
+ RE = /\A#{W}x?#{H}#{X}#{Y}([!<>@\^]?)\Z/
77
88
 
78
89
  def Geometry.from_s(str)
79
- Kernel.raise(ArgumentError, "no geometry string specified") unless str
80
90
 
81
91
  m = RE.match(str)
82
92
  if m
83
- width = m[1].to_i
84
- height = m[2].to_i
85
- x = m[3].to_i
86
- y = m[4].to_i
87
- flag = RFLAGS[m[5]]
93
+ width = (m[1] || m[2]).to_f
94
+ height = (m[3] || m[4]).to_f
95
+ x = m[5].to_i
96
+ y = m[6].to_i
97
+ flag = RFLAGS[m[7]]
88
98
  else
89
99
  Kernel.raise ArgumentError, "invalid geometry format"
90
100
  end
101
+ if str['%']
102
+ flag = PercentGeometry
103
+ end
91
104
  Geometry.new(width, height, x, y, flag)
92
105
  end
93
106
 
94
107
  # Convert object to a geometry string
95
108
  def to_s
96
109
  str = ''
97
- str << sprintf("%d", @width+0.5) if @width > 0
98
- str << 'x' if (@width > 0 || @height > 0)
99
- str << sprintf("%d", @height+0.5) if @height > 0
100
- str << sprintf("%+d%+d", @x+0.5, @y+0.5) if (@x != 0 || @y != 0)
101
- str << FLAGS[@flag.to_i]
110
+ if @width > 0
111
+ fmt = @width.truncate == @width ? "%d" : "%.2f"
112
+ str << sprintf(fmt, @width)
113
+ str << '%' if @flag == PercentGeometry
114
+ end
115
+
116
+ if (@width > 0 && @flag != PercentGeometry) || (@height > 0)
117
+ str << 'x'
118
+ end
119
+
120
+ if @height > 0
121
+ fmt = @height.truncate == @height ? "%d" : "%.2f"
122
+ str << sprintf(fmt, @height)
123
+ str << '%' if @flag == PercentGeometry
124
+ end
125
+ str << sprintf("%+d%+d", @x, @y) if (@x != 0 || @y != 0)
126
+ if @flag != PercentGeometry
127
+ str << FLAGS[@flag.to_i]
128
+ end
129
+ str
102
130
  end
103
131
  end
104
132
 
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
  Gem::Specification.new do |s|
3
3
  s.name = %q{rmagick}
4
- s.version = "2.4.0"
4
+ s.version = "2.5.0"
5
5
  s.date = Date.today.to_s
6
6
  s.summary = %q{Ruby binding to ImageMagick}
7
7
  s.description = %q{RMagick is an interface between Ruby and ImageMagick.}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmagick
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Hunter
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-02 00:00:00 -04:00
12
+ date: 2008-06-08 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -358,6 +358,7 @@ files:
358
358
  - doc/ex/crop_with_gravity.rb
359
359
  - doc/ex/posterize.rb
360
360
  - doc/ex/add_noise.rb
361
+ - doc/ex/compose_mask.rb
361
362
  - doc/ex/evenodd.rb
362
363
  - doc/ex/ViewBox.rb
363
364
  - doc/ex/Skew.rb