Skip to content

Commit 4947c35

Browse files
committed
Add kodak effect example script and demo images in README
1 parent 3610575 commit 4947c35

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ PureJPEG.encode(source,
8585

8686
See [CREATIVE.md](CREATIVE.md) for detailed examples of the creative encoding options.
8787

88+
<table>
89+
<tr>
90+
<td align="center"><strong>Normal (q20)</strong></td>
91+
<td align="center"><strong>Scrambled quantization (q20)</strong></td>
92+
</tr>
93+
<tr>
94+
<td><img src="examples/peppers.jpg" width="360"></td>
95+
<td><img src="examples/peppers-funky.jpg" width="360"></td>
96+
</tr>
97+
</table>
98+
8899
Each stage of the JPEG pipeline is a separate module, so individual components (DCT, quantization, Huffman coding) can be replaced or extended independently which is kinda my plan here as I made this to play around with effects.
89100

90101
## Decoding (reading JPEGs!)

examples/kodak.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../lib/pure_jpeg"
3+
4+
if ARGV.length < 1
5+
$stderr.puts "Usage: #{$0} INPUT.jpg [OUTPUT.jpg] [quality]"
6+
exit 1
7+
end
8+
9+
input = ARGV[0]
10+
output = ARGV[1] || input.sub(/(\.\w+)$/, '_kodak\1')
11+
quality = (ARGV[2] || 20).to_i
12+
13+
image = PureJPEG.read(input)
14+
PureJPEG.encode(image, quality: quality, scramble_quantization: true).write(output)
15+
16+
puts "#{input} -> #{output} (#{File.size(output)} bytes, q#{quality}, scrambled quantization)"

0 commit comments

Comments
 (0)