dball-zoomifier 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+ Zoomifier
2
+ =========
3
+ _Version 1.3 (November 24, 2008)_
4
+
5
+ __Authors:__ [Donald Ball](mailto:donald.ball@gmail.com)
6
+
7
+ __Copyright:__ Copyright (c) 2008, Donald Ball
8
+
9
+ __License:__ Apache Public License, v2.0
10
+
11
+ Zoomifier is a ruby library for creating directories of tiled images suitable for viewing with the free Zoomify flash player:
12
+
13
+ http://www.zoomify.com/
14
+
15
+ as well as a rails plugin that provides a helper method to make adding zoomified images to your rails app very easy.
16
+
17
+ ## Installation
18
+
19
+ To install the plugin:
20
+
21
+ script/plugin install git://github.com/dball/zoomifier.git
22
+
23
+ If you want the standalone library for whatever reason:
24
+
25
+ sudo gem install dball-zoomifier
26
+
27
+ all this gets you is the zoomify script installed in your PATH, though, and the free convert released by Zoomify is quite a bit faster.
28
+
29
+ I'm working on a GemPlugin version, but I can't seem to figure out how you're supposed to have assets installed; there doesn't seem to be any command which runs the GemPlugin's install.rb script.
30
+
31
+ ## Testing
32
+
33
+ Install the rspec gem, if you don't already have it, then run spec spec from the vendor/plugins/zoomifier directory.
34
+
35
+ ## Usage
36
+
37
+ In your views, wherever you want a zoomified image:
38
+
39
+ <%= zoomify_image_tag ('image.jpg', { :id => 'foo', :width => 400, :height => 300 }) %>
40
+
41
+ This will render a zoomified image with the specified dimensions using the swfobject Javascript library. An image tag with given attributes, except for the id (which is used to tag the div wrapper), is generated as a fallback for users without Javascript, so feel free to feed it alt and title and all that other good stuff as you see fit.
42
+
43
+ The directory of zoomified tiles is create in the same directory as the image, using its name without its extension, e.g. image/ in this example. The images will be automatically created if they do not exist already, or if the image file is newer than its tiles. Bear in mind this process can be fairly slow for large images, and of course, there's no point in zoomifying small images, so be patient on your first request. If there's sufficient, or, hell, any interest, I could write up some rake tasks to do this ahead of time.
@@ -7,7 +7,6 @@ require 'rmagick'
7
7
  # See http://zoomify.com/ for more details.
8
8
  #
9
9
  # @author Donald A. Ball Jr. <donald.ball@gmail.com>
10
- # @version 1.2
11
10
  # @copyright (C) 2008 Donald A. Ball Jr.
12
11
  #
13
12
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,6 +34,9 @@ module Zoomifier
35
34
  #filename = File.expand_path(filename)
36
35
  outputdir = File.dirname(filename) + '/' + File.basename(filename, '.*')
37
36
  raise ArgumentError unless filename != outputdir
37
+ if File.directory?(outputdir) && File.file?(outputdir + '/ImageProperties.xml') && File.mtime(filename) <= File.mtime(outputdir + '/ImageProperties.xml')
38
+ return
39
+ end
38
40
  FileUtils.rm_rf(outputdir) if File.exists?(outputdir)
39
41
  Dir.mkdir(outputdir)
40
42
  tmpdir = "#{outputdir}/tmp"
@@ -43,6 +43,24 @@ describe Zoomifier do
43
43
  image.columns.should <= 256
44
44
  end
45
45
  end
46
+
47
+ it "should not recreate the tiles if the image date precedes them" do
48
+ old_timestamps = timestamps(@output)
49
+ sleep(1)
50
+ Zoomifier::zoomify(@input)
51
+ new_timestamps = timestamps(@output)
52
+ old_timestamps.should == new_timestamps
53
+ end
54
+
55
+ def timestamps(dir)
56
+ timestamps = {}
57
+ ['/ImageProperties.xml', '/TileGroup0/*.jpg'].each do |pattern|
58
+ Dir.glob(dir + pattern) do |filename|
59
+ timestamps[filename] = File.mtime(filename)
60
+ end
61
+ end
62
+ timestamps
63
+ end
46
64
  end
47
65
 
48
66
  describe "On a 2973x2159 JPEG file" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dball-zoomifier
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: "1.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Ball
@@ -28,7 +28,7 @@ executables:
28
28
  extensions: []
29
29
 
30
30
  extra_rdoc_files:
31
- - README.txt
31
+ - README.markdown
32
32
  files:
33
33
  - lib/zoomifier.rb
34
34
  - bin/zoomify
@@ -36,7 +36,7 @@ files:
36
36
  - spec/spec_helper.rb
37
37
  - spec/data/1024x768.jpg
38
38
  - spec/data/2973x2159.jpg
39
- - README.txt
39
+ - README.markdown
40
40
  has_rdoc: true
41
41
  homepage:
42
42
  post_install_message:
data/README.txt DELETED
@@ -1,4 +0,0 @@
1
- Zoomifier is a ruby library for creating directories of tiled images
2
- suitable for viewing with the free Zoomify flash player:
3
-
4
- http://www.zoomify.com/