scrub_jpeg 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.md +78 -0
- data/Rakefile +1 -0
- data/bin/scrub_jpeg +46 -0
- data/bin/view_jpeg_info +20 -0
- data/lib/scrub_jpeg.rb +55 -0
- data/lib/scrub_jpeg/version.rb +3 -0
- data/scrub_jpeg.gemspec +24 -0
- metadata +67 -0
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
Scrub JPEG
|
2
|
+
==========
|
3
|
+
|
4
|
+
Why do I need this?
|
5
|
+
-------------------
|
6
|
+
|
7
|
+
Whenever you upload photos to the web, need to really compress JPEGs, or want
|
8
|
+
to hide embarrassing details about how exactly this photo came to be, you need
|
9
|
+
to cover all your tracks.
|
10
|
+
|
11
|
+
More likely, you may be a photographer who wants to keep his shiny new lens
|
12
|
+
parameters his very own little trade secret.
|
13
|
+
|
14
|
+
|
15
|
+
What do I do?
|
16
|
+
--------------
|
17
|
+
|
18
|
+
Exiv2 bindings are required. On MacOSX I suggest homebrew:
|
19
|
+
|
20
|
+
`brew install exiv2`
|
21
|
+
|
22
|
+
Then just grab the gem:
|
23
|
+
|
24
|
+
`gem install scrub_jpeg`
|
25
|
+
|
26
|
+
|
27
|
+
What exactly do I get?
|
28
|
+
----------------------
|
29
|
+
|
30
|
+
### View photo metadata
|
31
|
+
|
32
|
+
`$ view_jpeg_info bachelor_party.jpg`
|
33
|
+
|
34
|
+
Shows all the incriminating EXIF, IPTC, and XMP tags your friends may have
|
35
|
+
slyly add to your photo.
|
36
|
+
|
37
|
+
### Destroy photo metadata
|
38
|
+
|
39
|
+
$ scrub_jpeg bachelor_party.jpg
|
40
|
+
$ scrub_jpeg foo/bar/*.jpg
|
41
|
+
$ scrub_jpeg .
|
42
|
+
$ scrub_jpeg "my/photos/" "more/photos/*.jp"
|
43
|
+
|
44
|
+
Removes all EXIF, IPTC, and XMP tags, leaving only your actual facial expression
|
45
|
+
to incriminate you. But hey, that's why we have Photoshop™.
|
46
|
+
|
47
|
+
The arguments are one or more files, directories, or shell splats. Directories
|
48
|
+
are not searched recursively and only pick up files with `jpg` or `jpeg` extensions.
|
49
|
+
|
50
|
+
**WARNING:** This will overwrite the existing image. Make sure you have backups
|
51
|
+
and be aware you are deleting all metadata tags. No undo, no passing go, no collecting $200.
|
52
|
+
|
53
|
+
|
54
|
+
Why not X, Y, or Z?
|
55
|
+
-------------------
|
56
|
+
|
57
|
+
I did not want to write code, I just wanted something that worked predictably.
|
58
|
+
|
59
|
+
The existing choices were either convoluted GUI editors that did lots of image
|
60
|
+
manipulation related tasks, or poorly written shell scripts.
|
61
|
+
|
62
|
+
The closest thing I could find was `jhead -purejpeg`, which looked like my meal
|
63
|
+
ticket, until I ran it on some images and found it modified the actual images!
|
64
|
+
|
65
|
+
`scrub_jpeg` uses exiv2 to delete all metadata tags, but will never modify the
|
66
|
+
actual image. Hopefully it just does one thing well.
|
67
|
+
|
68
|
+
|
69
|
+
Disclaimer
|
70
|
+
----------
|
71
|
+
|
72
|
+
This is alpha software.
|
73
|
+
|
74
|
+
It is provided "AS IS" and without any express or implied warranties, including,
|
75
|
+
without limitation, the implied warranties of merchantability and fitness for
|
76
|
+
a particular purpose.
|
77
|
+
|
78
|
+
Use at your own risk. And make plenty of backups.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/scrub_jpeg
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "scrub_jpeg"
|
4
|
+
|
5
|
+
def parse_files(args)
|
6
|
+
files = []
|
7
|
+
args.each do |argv|
|
8
|
+
Dir.glob(argv).each do |f_or_d|
|
9
|
+
next unless File.exists?(f_or_d)
|
10
|
+
if File.file?(f_or_d)
|
11
|
+
next unless f_or_d =~ /\.jpe?g/i
|
12
|
+
files << f_or_d
|
13
|
+
elsif File.directory?(f_or_d)
|
14
|
+
splat = File.expand_path(f_or_d) + '/*'
|
15
|
+
Dir[splat].each do |f|
|
16
|
+
next unless f =~ /\.jpe?g/i
|
17
|
+
files << f
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
files
|
23
|
+
end
|
24
|
+
|
25
|
+
def scrub_files(files)
|
26
|
+
files.each do |filename|
|
27
|
+
scrubber = ScrubJpeg::Scrubber.new(filename)
|
28
|
+
scrubber.scrub!
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
USAGE = <<EOS
|
33
|
+
Usage: scrub_jpeg [INPUT]
|
34
|
+
|
35
|
+
where INPUT may be:
|
36
|
+
1) file.jpg
|
37
|
+
2) *splat*.jpg
|
38
|
+
3) /path/to/dir
|
39
|
+
EOS
|
40
|
+
|
41
|
+
if ARGV.empty?
|
42
|
+
puts USAGE
|
43
|
+
exit 0
|
44
|
+
else
|
45
|
+
scrub_files(parse_files(ARGV))
|
46
|
+
end
|
data/bin/view_jpeg_info
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'exiv2'
|
4
|
+
|
5
|
+
filename = ARGV[0] or fail 'Missing filename'
|
6
|
+
|
7
|
+
image = Exiv2::ImageFactory.open(filename)
|
8
|
+
image.read_metadata
|
9
|
+
|
10
|
+
image.iptc_data.each do |key, value|
|
11
|
+
puts "#{key} = #{value}\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
image.exif_data.each do |key, value|
|
15
|
+
puts "#{key} = #{value}\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
image.xmp_data.each do |key, value|
|
19
|
+
puts "#{key} = #{value}\n"
|
20
|
+
end
|
data/lib/scrub_jpeg.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "scrub_jpeg/version"
|
2
|
+
require 'exiv2'
|
3
|
+
|
4
|
+
module ScrubJpeg
|
5
|
+
class Scrubber
|
6
|
+
def initialize(filename)
|
7
|
+
info "Scrubbing... #{filename}"
|
8
|
+
@image = Exiv2::ImageFactory.open(filename)
|
9
|
+
@image.read_metadata
|
10
|
+
rescue Exiv2::BasicError
|
11
|
+
warn "Cannot open file: #{filename}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def scrub!
|
15
|
+
delete_all_iptc_tags
|
16
|
+
delete_all_exif_tags
|
17
|
+
delete_all_xmp_tags
|
18
|
+
@image.write_metadata
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def iptc_tags
|
24
|
+
@image.iptc_data.map(&:first)
|
25
|
+
end
|
26
|
+
|
27
|
+
def exif_tags
|
28
|
+
@image.exif_data.map(&:first)
|
29
|
+
end
|
30
|
+
|
31
|
+
def xmp_tags
|
32
|
+
@image.xmp_data.map(&:first)
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_all_iptc_tags
|
36
|
+
iptc_tags.each { |x| @image.iptc_data.delete_all(x) }
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_all_exif_tags
|
40
|
+
exif_tags.each { |x| @image.exif_data.delete_all(x) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def delete_all_xmp_tags
|
44
|
+
xmp_tags.each { |x| @image.xmp_data.delete_all(x) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def info(msg)
|
48
|
+
puts "#{msg}"
|
49
|
+
end
|
50
|
+
|
51
|
+
def warn(msg)
|
52
|
+
puts "[WARNING] #{msg}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/scrub_jpeg.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "scrub_jpeg/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "scrub_jpeg"
|
7
|
+
s.version = ScrubJpeg::VERSION
|
8
|
+
s.authors = ["Norbert Wojtowicz"]
|
9
|
+
s.email = ["wojtowicz.norbert@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/pithyless/scrub_jpeg"
|
11
|
+
s.summary = "Scrubs your images free of all metadata tags."
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "scrub_jpeg"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency 'exiv2', '0.0.6'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scrub_jpeg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Norbert Wojtowicz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-04 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: exiv2
|
16
|
+
requirement: &70272426498160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70272426498160
|
25
|
+
description: Scrubs your images free of all metadata tags.
|
26
|
+
email:
|
27
|
+
- wojtowicz.norbert@gmail.com
|
28
|
+
executables:
|
29
|
+
- scrub_jpeg
|
30
|
+
- view_jpeg_info
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- bin/scrub_jpeg
|
39
|
+
- bin/view_jpeg_info
|
40
|
+
- lib/scrub_jpeg.rb
|
41
|
+
- lib/scrub_jpeg/version.rb
|
42
|
+
- scrub_jpeg.gemspec
|
43
|
+
homepage: https://github.com/pithyless/scrub_jpeg
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: scrub_jpeg
|
63
|
+
rubygems_version: 1.8.6
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Scrubs your images free of all metadata tags.
|
67
|
+
test_files: []
|