photile 0.1.5 → 0.1.6
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.md +19 -24
- data/Rakefile +1 -1
- data/lib/photile.rb +1 -0
- data/lib/photile/cli.rb +11 -1
- data/photile.gemspec +5 -2
- data/test/{test_photile.rb → test_requirements.rb} +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# photile
|
2
2
|
|
3
|
-
* * *
|
4
|
-
*A ruby gem/library to chop a photo into tiles, watermark them, etc*
|
5
|
-
* * *
|
6
|
-
|
7
3
|
`photile` can be used to power a web widget like [turnandzoom](https://github.com/nitindhar7/turnandzoom) or just about any simple image processing workflow. With `photile` you can run simple tasks like compression, watermarking and tiling images manually or in an automated fashion. These tasks can be combined to formulate a custom flow. For example, you can `compress an image` → `watermark it` → `break it up into tiles`.
|
8
4
|
|
9
5
|
One scenario where this is really useful is image processing for product images. Most product images are shot on white background, which means that there is a big opportunity to reduce image size and improve rendering speed on the web page. Here's what you can do with `photile`: `basic quality reduction` → `watermark your product images` → `break it up into tiles (certain tiles will be all white)` → `compress individual tiles`.
|
@@ -31,44 +27,43 @@ Usage: photile [options] infile outfile
|
|
31
27
|
-h, --help Display options help
|
32
28
|
|
33
29
|
# Basic Examples
|
34
|
-
$ photile
|
35
|
-
$ photile
|
36
|
-
$ photile
|
37
|
-
$ photile
|
30
|
+
$ photile --quality 80 image-in image-out
|
31
|
+
$ photile --compress image-in image-out
|
32
|
+
$ photile --watermark image-in image-watermark image-out
|
33
|
+
$ photile --tile WIDTHxHEIGHT image-in image-out
|
38
34
|
|
39
35
|
# Advanced Examples
|
40
36
|
|
41
37
|
# 1. Reduce quality and then loss less compression for 'image-in' to produce 'image-out'
|
42
|
-
$ photile
|
38
|
+
$ photile --quality 80 --compress image-in image-out
|
43
39
|
|
44
40
|
# 2. Watermark 'image-in' with 'image-watermark' and then tile it with size 'WIDTHxHEIGHT' to produce '[image-out-0...image-out-n]'
|
45
|
-
$ photile
|
41
|
+
$ photile --watermark --tile WIDTHxHEIGHT image-in image-watermark image-out
|
46
42
|
|
47
|
-
# 3. Reduce quality of 'image-in', then compress it and watermark it with 'image-watermark'. Finally, tile the watermarked image to produce '[image-out-0...image-out-n]'
|
48
|
-
$ photile
|
43
|
+
# 3. Reduce quality % of 'image-in', then compress it and watermark it with 'image-watermark'. Finally, tile the watermarked image to produce '[image-out-0...image-out-n]'
|
44
|
+
$ photile --quality QUALITY --compress --watermark image-watermark --tile WIDTHxHEIGHT image-in image-out
|
49
45
|
```
|
50
46
|
|
51
47
|
### Features
|
52
48
|
|
53
|
-
* Quality manipulation
|
54
|
-
* Loss-less compression
|
55
|
-
* Watermarking
|
56
|
-
* Tiling
|
57
|
-
|
58
|
-
### Piping
|
59
|
-
|
60
49
|
The four main functions of `photile` can be used in all combinations possible because of their 'piping' properties (i.e., the Builder Pattern). Each function takes in an image and spits out an image or an array of images. When an array of images is returned any function thereafter is applied to all items in the array. When piping functions the order is relevant as the output of a function becomes the input of another. For example: `tile` → `watermark` (tiles images and then applies a watermark to the smaller, chopped images) is not the same as `watermark` → `tile` (watermarks an image and then creates tiles).
|
61
50
|
|
62
51
|
Here are the piping scenarios available
|
63
52
|
|
64
|
-
* `IMAGE` → `Quality Modifier` → `IMAGE`
|
65
|
-
* `IMAGE` → `Compressor` → `IMAGE`
|
66
|
-
* `IMAGE` + `WATERMARK IMAGE` → `Watermarker` → `IMAGE`
|
67
|
-
* `IMAGE` → `Tiler` → `[IMAGE...IMAGE]`
|
53
|
+
* Quality manipulation: `IMAGE` → `Quality Modifier` → `IMAGE`
|
54
|
+
* Loss-less compression: `IMAGE` → `Compressor` → `IMAGE`
|
55
|
+
* Watermarking: `IMAGE` + `WATERMARK IMAGE` → `Watermarker` → `IMAGE`
|
56
|
+
* Tiling: `IMAGE` → `Tiler` → `[IMAGE...IMAGE]`
|
68
57
|
|
69
|
-
###
|
58
|
+
### Moreoe
|
70
59
|
|
71
60
|
Photile uses the amazing [Imagemagick](http://www.imagemagick.org/script/index.php) 6.6.9-7 and [Jpegtran](http://jpegclub.org/jpegtran/) 1.2.0 libraries. Imagemagick provides quality, watermarking and tiling properties. Jpegtran provides the loss-less compression. In other words, `photile` is just a layer on top of existing libraries to make certain image processing tasks dead simple. Additionally since `photile` is a gem it can be used directly in Rails to create dynamic workflows.
|
72
61
|
|
62
|
+
### TODO
|
63
|
+
|
64
|
+
- CLI option to show version
|
65
|
+
- File validation for infile/outfile
|
66
|
+
- More unit tests to ensure that all pipe permutations work
|
67
|
+
|
73
68
|
* * *
|
74
69
|
Copyright (c) 2013 Nitin Dhar. See [MIT-LICENSE](MIT-LICENSE) for details.
|
data/Rakefile
CHANGED
data/lib/photile.rb
CHANGED
data/lib/photile/cli.rb
CHANGED
@@ -24,8 +24,13 @@ class Photile::Cli
|
|
24
24
|
options << {:tile => {:width => dim.first.to_i, :height => dim.last.to_i}}
|
25
25
|
end
|
26
26
|
|
27
|
+
opts.on('-v', '--[no-]verbose', 'Run verbosely') do |value|
|
28
|
+
options << {:verbose => value}
|
29
|
+
end
|
30
|
+
|
27
31
|
opts.on('-h', '--help', 'Display options help') do
|
28
32
|
puts opts
|
33
|
+
puts 'photile requires the following libraries to be installed: imagemagick, imagemagick-common and libjpeg-turbo-progs'
|
29
34
|
exit
|
30
35
|
end
|
31
36
|
end
|
@@ -35,12 +40,17 @@ class Photile::Cli
|
|
35
40
|
|
36
41
|
if options.empty? || ARGV.size != 2
|
37
42
|
puts optparse
|
43
|
+
puts 'photile requires the following libraries to be installed: imagemagick, imagemagick-common and libjpeg-turbo-progs'
|
38
44
|
exit
|
39
45
|
end
|
40
46
|
|
41
47
|
{:options => options, :infile => ARGV.first, :outfile => ARGV.last}
|
42
48
|
rescue OptionParser::InvalidArgument => ia
|
43
|
-
puts
|
49
|
+
puts 'Invalid argument'
|
50
|
+
puts optparse
|
51
|
+
exit
|
52
|
+
rescue OptionParser::InvalidOption => io
|
53
|
+
puts 'Invalid option'
|
44
54
|
puts optparse
|
45
55
|
exit
|
46
56
|
end
|
data/photile.gemspec
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "photile"
|
3
|
+
|
1
4
|
Gem::Specification.new do |s|
|
2
5
|
s.name = 'photile'
|
3
|
-
s.version =
|
6
|
+
s.version = Photile::VERSION
|
4
7
|
s.date = Time.now.strftime("%Y-%m-%d")
|
5
8
|
s.summary = 'A ruby gem to compress a photo, chop it into tiles, watermark it, etc.'
|
6
9
|
s.description = 'Photile is just a layer on top of Imagemagick and Jpegtran to make certain image processing tasks dead simple.'
|
@@ -14,4 +17,4 @@ Gem::Specification.new do |s|
|
|
14
17
|
s.add_development_dependency 'rake', ['>= 0.8.7']
|
15
18
|
s.required_ruby_version = '>= 1.8.7'
|
16
19
|
s.requirements << 'imagemagick' << 'imagemagick-common' << 'libjpeg-turbo-progs'
|
17
|
-
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
- lib/photile.rb
|
44
44
|
- lib/photile/cli.rb
|
45
45
|
- photile.gemspec
|
46
|
-
- test/
|
46
|
+
- test/test_requirements.rb
|
47
47
|
homepage: https://github.com/nitindhar7/photile
|
48
48
|
licenses:
|
49
49
|
- MIT
|