c2pa_xmp_probe 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5d91748265f2d95157a5ea1b529b502016b71ac8528fcc7b4eb23697eb861aac
4
+ data.tar.gz: f57cc984eb4e65dd956ec04a032b61bbec5dfa8cabdabbb7aea50fdb00f5924d
5
+ SHA512:
6
+ metadata.gz: bdc98541a6d0ccb9954bb08bdb5d944a9e2f9402c3ed6ba5f98103eebe4352deb39615f58af38a0e5edfe1c3a35884100204665ee68560df5f1880f4aab6f7f4
7
+ data.tar.gz: f786f52ac8cc0996baecb289fa5a8c7f42f30dfcae9f9c9c1254c8427b021282cd2e6addc2b8de1c8b69f68ed991edc94f755371d64cb330d079141f13c17fed
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 removeailabel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # c2pa_xmp_probe
2
+
3
+ Scan JPG/PNG/WebP (or any file) for byte-level C2PA, XMP, and common AI provenance markers before you upload to Instagram, TikTok, or similar.
4
+
5
+ This is a local probe only. It does not rewrite files.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ gem install c2pa_xmp_probe
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ c2pa-xmp-probe photo.jpg
17
+ c2pa-xmp-probe --json export.png still.webp
18
+ ```
19
+
20
+ ```ruby
21
+ require "c2pa_xmp_probe"
22
+
23
+ result = C2paXmpProbe.probe_file("export.jpg")
24
+ puts result.matched if result.flagged?
25
+ ```
26
+
27
+ Exit codes: `0` = no markers, `1` = flagged, `2` = missing path / IO error.
28
+
29
+ If a still is flagged, keep the archive master and export a separate upload copy. For stripping provenance on that social-facing JPEG only, use a [browser-side prep step before Instagram or TikTok](https://removeailabel.com), then upload the cleaned file.
30
+
31
+ ## License
32
+
33
+ MIT
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/c2pa_xmp_probe"
5
+
6
+ def print_help
7
+ puts <<~HELP
8
+ Usage: c2pa-xmp-probe [--json] <file> [file...]
9
+
10
+ Scan files for C2PA / XMP / common AI provenance byte markers.
11
+ Exit: 0 = clean, 1 = flagged, 2 = usage / IO error.
12
+ HELP
13
+ end
14
+
15
+ args = ARGV.dup
16
+ if args.empty? || args.include?("-h") || args.include?("--help")
17
+ print_help
18
+ exit(args.empty? ? 2 : 0)
19
+ end
20
+
21
+ json = args.delete("--json")
22
+ if args.empty?
23
+ print_help
24
+ exit 2
25
+ end
26
+
27
+ any_flagged = false
28
+ results = []
29
+
30
+ args.each do |file|
31
+ begin
32
+ result = C2paXmpProbe.probe_file(file)
33
+ results << result
34
+ any_flagged ||= result.flagged?
35
+ next if json
36
+
37
+ status = result.flagged? ? "FLAGGED" : "clean"
38
+ bits = [
39
+ (result.has_c2pa ? "c2pa" : nil),
40
+ (result.has_xmp ? "xmp" : nil),
41
+ (result.has_ai_hint ? "ai-hint" : nil)
42
+ ].compact.join(",")
43
+ puts [status, file, (bits.empty? ? nil : bits)].compact.join("\t")
44
+ rescue StandardError => e
45
+ warn "error\t#{file}\t#{e.message}"
46
+ exit 2
47
+ end
48
+ end
49
+
50
+ if json
51
+ payload = results.map do |r|
52
+ {
53
+ path: r.path,
54
+ size: r.size,
55
+ has_c2pa: r.has_c2pa,
56
+ has_xmp: r.has_xmp,
57
+ has_ai_hint: r.has_ai_hint,
58
+ matched: r.matched,
59
+ flagged: r.flagged?
60
+ }
61
+ end
62
+ require "json"
63
+ puts JSON.pretty_generate(payload)
64
+ end
65
+
66
+ exit(any_flagged ? 1 : 0)
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module C2paXmpProbe
4
+ VERSION = "0.1.0"
5
+
6
+ C2PA_MARKERS = %w[c2pa C2PA jumb c2ma c2cl c2cs c2as].freeze
7
+
8
+ XMP_MARKERS = [
9
+ "http://ns.adobe.com/xap/1.0/",
10
+ "<x:xmpmeta",
11
+ "xmlns:xmp",
12
+ "photoshop:DocumentAncestors"
13
+ ].freeze
14
+
15
+ AI_HINT_MARKERS = [
16
+ "Firefly",
17
+ "Midjourney",
18
+ "Stable Diffusion",
19
+ "DALL-E",
20
+ "DALL·E",
21
+ "Content Credentials",
22
+ "madewithai",
23
+ "Made with AI"
24
+ ].freeze
25
+
26
+ Result = Struct.new(
27
+ :path, :size, :has_c2pa, :has_xmp, :has_ai_hint, :matched,
28
+ keyword_init: true
29
+ ) do
30
+ def flagged?
31
+ has_c2pa || has_xmp || has_ai_hint
32
+ end
33
+ end
34
+
35
+ module_function
36
+
37
+ def probe_bytes(data, path: "<memory>")
38
+ matched = []
39
+ has_c2pa = false
40
+ has_xmp = false
41
+ has_ai_hint = false
42
+
43
+ C2PA_MARKERS.each do |marker|
44
+ next unless data.include?(marker)
45
+
46
+ has_c2pa = true
47
+ matched << marker
48
+ end
49
+
50
+ XMP_MARKERS.each do |marker|
51
+ next unless data.include?(marker)
52
+
53
+ has_xmp = true
54
+ matched << marker[0, 48]
55
+ end
56
+
57
+ AI_HINT_MARKERS.each do |marker|
58
+ next unless data.include?(marker)
59
+
60
+ has_ai_hint = true
61
+ matched << marker
62
+ end
63
+
64
+ Result.new(
65
+ path: path,
66
+ size: data.bytesize,
67
+ has_c2pa: has_c2pa,
68
+ has_xmp: has_xmp,
69
+ has_ai_hint: has_ai_hint,
70
+ matched: matched.uniq
71
+ )
72
+ end
73
+
74
+ def probe_file(file_path)
75
+ data = File.binread(file_path)
76
+ probe_bytes(data, path: file_path)
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c2pa_xmp_probe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - removeailabel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2026-08-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Local CLI/library to scan files for C2PA, XMP, and common AI provenance
14
+ byte markers before social upload. Does not rewrite files.
15
+ email:
16
+ - hiltonlee981@gmail.com
17
+ executables:
18
+ - c2pa-xmp-probe
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - LICENSE
23
+ - README.md
24
+ - exe/c2pa-xmp-probe
25
+ - lib/c2pa_xmp_probe.rb
26
+ homepage: https://removeailabel.com
27
+ licenses:
28
+ - MIT
29
+ metadata:
30
+ homepage_uri: https://removeailabel.com
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.7.0
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ requirements: []
46
+ rubygems_version: 3.5.22
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Probe image bytes for C2PA, XMP, and common AI provenance markers.
50
+ test_files: []