couch_photo 1.0.0.beta.1 → 1.0.0.beta.2
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/README.markdown +46 -31
- data/VERSION +1 -1
- data/lib/couch_photo/couch_photo.rb +2 -2
- metadata +4 -4
data/README.markdown
CHANGED
@@ -1,15 +1,27 @@
|
|
1
|
-
#
|
1
|
+
#CouchPhoto
|
2
2
|
|
3
|
-
|
3
|
+
[](http://travis-ci.org/moonmaster9000/couch_photo)
|
4
|
+
|
5
|
+
`CouchPhoto` is a mixin for auto-generating image variations on Image documents with CouchDB.
|
4
6
|
|
5
7
|
##Installation
|
6
8
|
|
9
|
+
`CouchPhoto` is available as a gem. You can install it directly via:
|
10
|
+
|
7
11
|
```sh
|
8
|
-
|
12
|
+
$ gem install couch_photo --pre
|
9
13
|
```
|
14
|
+
|
15
|
+
Or, you can add the following to your projects `Gemfile` if you're using `bundler`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem "couch_photo", '~> 1.0.0.beta.1'
|
19
|
+
```
|
20
|
+
|
21
|
+
|
10
22
|
## Documentation
|
11
23
|
|
12
|
-
Browse the documentation on
|
24
|
+
Browse the documentation on relishapp.com: http://relishapp.com/moonmaster9000/couch-photo
|
13
25
|
|
14
26
|
##How does it work?
|
15
27
|
|
@@ -222,33 +234,6 @@ These images would be accessible via the following urls:
|
|
222
234
|
http://your_couch_server/your_image_database/somefile.jpg/variations/large_watermark.jpg
|
223
235
|
|
224
236
|
|
225
|
-
## XMP Metadata
|
226
|
-
|
227
|
-
Need to access the XMP Metadata on your original? It's as simple as adding `extract_xmp_metadata!` into your document definition.
|
228
|
-
|
229
|
-
```ruby
|
230
|
-
class Image < CouchRest::Model::Base
|
231
|
-
use_database IMAGE_DB
|
232
|
-
include CouchPhoto
|
233
|
-
|
234
|
-
extract_xmp_metadata!
|
235
|
-
override_id! # the id of the document will be the basename of the original image file
|
236
|
-
|
237
|
-
variations do
|
238
|
-
small "20x20"
|
239
|
-
medium "100x100"
|
240
|
-
large "500x500"
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
i = Image.new
|
245
|
-
i.load_original_from_file "avatar.jpg"
|
246
|
-
i.save
|
247
|
-
```
|
248
|
-
|
249
|
-
Now you can access your image's XMP metadata as a hash by calling `i.xmp_metadata`.
|
250
|
-
|
251
|
-
|
252
237
|
## Adding extra properties to your variations
|
253
238
|
|
254
239
|
Perhaps you'd like to add some extra properties that you can save for each of your image variations, like "alt" text, or captions. Simply use the `metadata` hash on your variations.
|
@@ -277,3 +262,33 @@ You could now set any metadata properties you desire on your variations:
|
|
277
262
|
@image.variations[:grayscale].metadata["caption"] = "Grayscale version of: #{@image.original.url}"
|
278
263
|
@image.save
|
279
264
|
```
|
265
|
+
|
266
|
+
|
267
|
+
## XMP Metadata
|
268
|
+
|
269
|
+
Need to access the XMP Metadata on your original? It's as simple as adding `extract_xmp_metadata!` into your document definition.
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
class Image < CouchRest::Model::Base
|
273
|
+
use_database IMAGE_DB
|
274
|
+
include CouchPhoto
|
275
|
+
|
276
|
+
extract_xmp_metadata!
|
277
|
+
override_id! # the id of the document will be the basename of the original image file
|
278
|
+
|
279
|
+
variations do
|
280
|
+
small "20x20"
|
281
|
+
medium "100x100"
|
282
|
+
large "500x500"
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
i = Image.new
|
287
|
+
i.load_original_from_file "avatar.jpg"
|
288
|
+
i.save
|
289
|
+
```
|
290
|
+
|
291
|
+
Now you can access your image's XMP metadata as a hash by calling `i.xmp_metadata`.
|
292
|
+
|
293
|
+
|
294
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.beta.
|
1
|
+
1.0.0.beta.2
|
@@ -8,7 +8,7 @@ module CouchPhoto
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
def override_id!
|
11
|
-
self.
|
11
|
+
self.before_validate :set_id_to_original_filename
|
12
12
|
end
|
13
13
|
|
14
14
|
def extract_xmp_metadata!
|
@@ -102,7 +102,7 @@ module CouchPhoto
|
|
102
102
|
if self.original_filename.blank?
|
103
103
|
self.errors.add :original, "must be set before create"
|
104
104
|
else
|
105
|
-
self.id = self.original_filename
|
105
|
+
self.id = self.original_filename if self.id.blank?
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couch_photo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196359
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 1.0.0.beta.
|
11
|
+
- 2
|
12
|
+
version: 1.0.0.beta.2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Parker
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-09-
|
20
|
+
date: 2011-09-26 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: cucumber
|