image_science 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.1.3 / 2007-05-30
2
+
3
+ * 2 minor enhancements:
4
+ * Added quick_thumb as an example to look at.
5
+ * Error handler doesn't raise by default. Raises if $DEBUG==true.
6
+
1
7
  == 1.1.2 / 2007-04-18
2
8
 
3
9
  * 2 bug fixes:
data/Manifest.txt CHANGED
@@ -4,5 +4,6 @@ README.txt
4
4
  Rakefile
5
5
  bench.rb
6
6
  lib/image_science.rb
7
+ quick_thumb
7
8
  test/pix.png
8
9
  test/test_image_science.rb
data/lib/image_science.rb CHANGED
@@ -11,7 +11,7 @@ require 'inline'
11
11
  # http://seattlerb.rubyforge.org/ImageScience.html
12
12
 
13
13
  class ImageScience
14
- VERSION = '1.1.2'
14
+ VERSION = '1.1.3'
15
15
 
16
16
  ##
17
17
  # The top-level image loader opens +path+ and then yields the image.
@@ -86,13 +86,16 @@ class ImageScience
86
86
  builder.add_compile_flags "-I/opt/local/include"
87
87
  builder.add_link_flags "-L/opt/local/lib"
88
88
  end
89
+
89
90
  builder.add_link_flags "-lfreeimage"
90
91
  builder.add_link_flags "-lstdc++" # only needed on PPC for some reason. lame
91
92
  builder.include '"FreeImage.h"'
92
93
 
93
94
  builder.prefix <<-"END"
94
95
  #define GET_BITMAP(name) FIBITMAP *(name); Data_Get_Struct(self, FIBITMAP, (name)); if (!(name)) rb_raise(rb_eTypeError, "Bitmap has already been freed")
96
+ END
95
97
 
98
+ builder.prefix <<-"END"
96
99
  VALUE unload(VALUE self) {
97
100
  GET_BITMAP(bitmap);
98
101
 
@@ -100,7 +103,9 @@ class ImageScience
100
103
  DATA_PTR(self) = NULL;
101
104
  return Qnil;
102
105
  }
106
+ END
103
107
 
108
+ builder.prefix <<-"END"
104
109
  VALUE wrap_and_yield(FIBITMAP *image, VALUE self, FREE_IMAGE_FORMAT fif) {
105
110
  VALUE klass = fif ? self : CLASS_OF(self);
106
111
  VALUE type = fif ? INT2FIX(fif) : rb_iv_get(self, "@file_type");
@@ -108,7 +113,9 @@ class ImageScience
108
113
  rb_iv_set(obj, "@file_type", type);
109
114
  return rb_ensure(rb_yield, obj, unload, obj);
110
115
  }
116
+ END
111
117
 
118
+ builder.prefix <<-"END"
112
119
  void copy_icc_profile(VALUE self, FIBITMAP *from, FIBITMAP *to) {
113
120
  FREE_IMAGE_FORMAT fif = FIX2INT(rb_iv_get(self, "@file_type"));
114
121
  if (fif != FIF_PNG && FreeImage_FIFSupportsICCProfiles(fif)) {
@@ -122,6 +129,7 @@ class ImageScience
122
129
 
123
130
  builder.prefix <<-"END"
124
131
  void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
132
+ if (! RTEST(ruby_debug)) return;
125
133
  rb_raise(rb_eRuntimeError,
126
134
  "FreeImage exception for type %s: %s",
127
135
  (fif == FIF_UNKNOWN) ? "???" : FreeImage_GetFormatFromFIF(fif),
data/quick_thumb ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ abort "#{File.basename $0} max_length files..." unless ARGV.size > 1
4
+
5
+ require 'rubygems'
6
+ require 'image_science'
7
+
8
+ max_length = ARGV.shift.to_i
9
+
10
+ ARGV.each do |file|
11
+ begin
12
+ result = ImageScience.with_image file do |img|
13
+ begin
14
+ img.thumbnail(max_length) do |thumb|
15
+ # add _thumb and switch from gif to png. Really. gif just sucks.
16
+ out = file.sub(/(\.[^\.]+)$/, '_thumb\1').sub(/gif$/, 'png')
17
+ thumb.save(out)
18
+ end
19
+ rescue => e
20
+ warn "Exception thumbnailing #{file}: #{e}"
21
+ end
22
+ end
23
+ p file => result
24
+ rescue => e
25
+ warn "Exception opening #{file}: #{e}"
26
+ end
27
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.9
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: image_science
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.2
7
- date: 2007-04-18 00:00:00 -04:00
6
+ version: 1.1.3
7
+ date: 2007-05-30 00:00:00 -04:00
8
8
  summary: ImageScience is a clean and happy Ruby library that generates thumbnails -- and kicks the living crap out of RMagick.
9
9
  require_paths:
10
10
  - lib
@@ -35,14 +35,18 @@ files:
35
35
  - Rakefile
36
36
  - bench.rb
37
37
  - lib/image_science.rb
38
+ - quick_thumb
38
39
  - test/pix.png
39
40
  - test/test_image_science.rb
40
41
  test_files:
41
42
  - test/test_image_science.rb
42
- rdoc_options: []
43
-
44
- extra_rdoc_files: []
45
-
43
+ rdoc_options:
44
+ - --main
45
+ - README.txt
46
+ extra_rdoc_files:
47
+ - History.txt
48
+ - Manifest.txt
49
+ - README.txt
46
50
  executables: []
47
51
 
48
52
  extensions: []
@@ -66,5 +70,5 @@ dependencies:
66
70
  requirements:
67
71
  - - ">="
68
72
  - !ruby/object:Gem::Version
69
- version: 1.2.0
73
+ version: 1.2.1
70
74
  version: