mini_magick 1.2.2 → 1.2.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.
Potentially problematic release.
This version of mini_magick might be problematic. Click here for more details.
- data/History.txt +5 -0
- data/lib/mini_magick.rb +12 -9
- data/test/test_mini_magick_test.rb +8 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -4,3 +4,8 @@
|
|
4
4
|
# 2.) identify doesn't trip over strangley named files
|
5
5
|
# 3.) TempFile uses file extention now (Thanks http://marsorange.com/archives/of-mogrify-ruby-tempfile-dynamic-class-definitions)
|
6
6
|
# 4.) identify commands escape output path correctly
|
7
|
+
|
8
|
+
== 1.2.3 / 2007-06-15
|
9
|
+
|
10
|
+
# 1.) Image::from_file doesn't drop the file extension anymore, it and use the image_temp_file correctly
|
11
|
+
# 4.) TempFiles are stored as an instance variable in Image instances so they don't get cleaned up prematurely via garbage collection
|
data/lib/mini_magick.rb
CHANGED
@@ -7,38 +7,41 @@ require File.join(File.dirname(__FILE__), '/image_temp_file')
|
|
7
7
|
module MiniMagick
|
8
8
|
class MiniMagickError < RuntimeError; end
|
9
9
|
|
10
|
-
VERSION = '1.2.
|
10
|
+
VERSION = '1.2.3'
|
11
11
|
|
12
12
|
class Image
|
13
13
|
attr :path
|
14
|
+
attr :tempfile
|
14
15
|
attr :output
|
15
16
|
|
16
17
|
# Class Methods
|
17
18
|
# -------------
|
18
19
|
class <<self
|
19
|
-
def from_blob(blob)
|
20
|
+
def from_blob(blob, extension=nil)
|
20
21
|
begin
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
tempfile = ImageTempFile.new("minimagick#{extension}")
|
23
|
+
tempfile.binmode
|
24
|
+
tempfile.write(blob)
|
24
25
|
ensure
|
25
|
-
|
26
|
+
tempfile.close
|
26
27
|
end
|
27
|
-
|
28
|
+
|
29
|
+
return self.new(tempfile.path, tempfile)
|
28
30
|
end
|
29
31
|
|
30
32
|
# Use this if you don't want to overwrite the image file
|
31
33
|
def from_file(image_path)
|
32
34
|
File.open(image_path, "rb") do |f|
|
33
|
-
self.from_blob(f.read)
|
35
|
+
self.from_blob(f.read, File.extname(image_path))
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
# Instance Methods
|
39
41
|
# ----------------
|
40
|
-
def initialize(input_path)
|
42
|
+
def initialize(input_path, tempfile=nil)
|
41
43
|
@path = input_path
|
44
|
+
@tempfile = tempfile # ensures that the tempfile will stick around until this image is garbage collected.
|
42
45
|
|
43
46
|
# Ensure that the file is an image
|
44
47
|
run_command("identify", @path)
|
@@ -7,6 +7,7 @@ class ImageTest < Test::Unit::TestCase
|
|
7
7
|
CURRENT_DIR = File.dirname(File.expand_path(__FILE__)) + "/"
|
8
8
|
|
9
9
|
SIMPLE_IMAGE_PATH = CURRENT_DIR + "simple.gif"
|
10
|
+
TIFF_IMAGE_PATH = CURRENT_DIR + "burner.tiff"
|
10
11
|
NOT_AN_IMAGE_PATH = CURRENT_DIR + "not_an_image.php"
|
11
12
|
GIF_WITH_JPG_EXT = CURRENT_DIR + "actually_a_gif.jpg"
|
12
13
|
EXIF_IMAGE_PATH = CURRENT_DIR + "trogdor.jpg"
|
@@ -49,6 +50,13 @@ class ImageTest < Test::Unit::TestCase
|
|
49
50
|
assert_equal 55, image[:height]
|
50
51
|
assert_match(/^gif$/i, image[:format])
|
51
52
|
end
|
53
|
+
|
54
|
+
def test_tiff
|
55
|
+
image = Image.new(TIFF_IMAGE_PATH)
|
56
|
+
assert_equal "tiff", image[:format].downcase
|
57
|
+
assert_equal 317, image[:width]
|
58
|
+
assert_equal 275, image[:height]
|
59
|
+
end
|
52
60
|
|
53
61
|
def test_gif_with_jpg_format
|
54
62
|
image = Image.new(GIF_WITH_JPG_EXT)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0.1
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mini_magick
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 1.2.3
|
7
|
+
date: 2007-06-15 00:00:00 -04:00
|
8
8
|
summary: A simple image manipulation library based on ImageMagick.
|
9
9
|
require_paths:
|
10
10
|
- lib
|