-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Needed for people that have problems to distinguish between red/green/black - Bumped version to 2.5.3
- Loading branch information
Showing
5 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
kidiff (2.5.3-1) stable; urgency=medium | ||
|
||
* Added new mode "2color" where you can control the added/removed colors | ||
|
||
-- Salvador Eduardo Tropea <[email protected]> Wed, 10 Jan 2024 09:54:13 -0300 | ||
|
||
kidiff (2.5.2-1) stable; urgency=medium | ||
|
||
* Added Smarter cache: changing KiCad or --zones option invalidates the cache | ||
* Fixed KiRi mode for KiCad 5: Plotting the worksheet makes KiCad crash, | ||
disabled | ||
|
||
-- Salvador Eduardo Tropea <[email protected]> Thu, 04 Jan 2024 10:41:43 -0300 | ||
-- Salvador Eduardo Tropea <[email protected]> Thu, 09 Jan 2024 10:41:43 -0300 | ||
|
||
kidiff (2.5.1-1) stable; urgency=medium | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
__copyright__ = 'Copyright 2020, INTI' | ||
__credits__ = ['Salvador E. Tropea'] | ||
__license__ = 'GPL 2.0' | ||
__version__ = '2.5.2' | ||
__version__ = '2.5.3' | ||
__email__ = '[email protected]' | ||
__status__ = 'beta' | ||
__url__ = 'https://github.com/INTI-CMNB/KiDiff/' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/python3 | ||
# Copyright (c) 2020-2023 Salvador E. Tropea | ||
# Copyright (c) 2020-2023 Instituto Nacional de Tecnologïa Industrial | ||
# Copyright (c) 2020-2024 Salvador E. Tropea | ||
# Copyright (c) 2020-2024 Instituto Nacional de Tecnología Industrial | ||
# License: GPL-2.0 | ||
# Project: KiCad Diff | ||
# Adapted from: https://github.com/obra/kicad-tools | ||
|
@@ -25,10 +25,10 @@ | |
""" | ||
__author__ = 'Salvador E. Tropea' | ||
__copyright__ = 'Copyright 2020-2023, INTI/'+__author__ | ||
__copyright__ = 'Copyright 2020-2024, INTI/'+__author__ | ||
__credits__ = ['Salvador E. Tropea', 'Jesse Vincent'] | ||
__license__ = 'GPL 2.0' | ||
__version__ = '2.5.2' | ||
__version__ = '2.5.3' | ||
__email__ = '[email protected]' | ||
__status__ = 'beta' | ||
__url__ = 'https://github.com/INTI-CMNB/KiDiff/' | ||
|
@@ -51,7 +51,7 @@ | |
from struct import unpack | ||
from subprocess import call, PIPE, run, STDOUT, CalledProcessError | ||
from sys import exit | ||
from tempfile import mkdtemp | ||
from tempfile import mkdtemp, NamedTemporaryFile | ||
import time | ||
|
||
# Exit error codes | ||
|
@@ -451,6 +451,45 @@ def create_diff_stereo(old_name, new_name, diff_name, font_size, layer, resoluti | |
return include | ||
|
||
|
||
def create_diff_stereo_colored(old_name, new_name, diff_name, font_size, layer, resolution, name_layer, only_different): | ||
""" A more complex version of create_diff_stereo where we can control the colors """ | ||
wn, hn = png_size(new_name) | ||
wo, ho = png_size(old_name) | ||
if wn != wo or hn != ho: | ||
extent = ' -extent {}x{}'.format(max(wn, wo), max(hn, ho)) | ||
extra_name = ' [diff page size]' | ||
else: | ||
extra_name = extent = '' | ||
with NamedTemporaryFile(mode='w', prefix='removed', suffix='.png', delete=False) as f: | ||
removed = f.name | ||
with NamedTemporaryFile(mode='w', prefix='added', suffix='.png', delete=False) as f: | ||
added = f.name | ||
command = ['bash', '-c', | ||
'( convert -threshold 50% "'+new_name+'"'+extent+' miff:- ;' + | ||
' convert -threshold 50% -negate "'+old_name+'"'+extent+' miff:- ) | ' + | ||
r'convert - -compose darken -composite -negate -fill "'+args.removed_2color+'" ' + | ||
' -opaque black -transparent white "'+removed+'"'] | ||
run_command(command) | ||
command = ['bash', '-c', | ||
'( convert -threshold 50% -negate "'+new_name+'"'+extent+' miff:- ;' + | ||
' convert -threshold 50% "'+old_name+'"'+extent+' miff:- ) | ' + | ||
r'convert - -compose darken -composite -negate -fill "'+args.added_2color+'" ' + | ||
' -opaque black -transparent white "'+added+'"'] | ||
run_command(command) | ||
run_command(['convert', old_name, added, '-composite', removed, '-composite', | ||
'-font', 'helvetica', '-pointsize', font_size, '-draw', | ||
"text 10,"+font_size+" '"+adapt_name(name_layer)+extra_name+"'", | ||
diff_name]) | ||
include = True | ||
if only_different: | ||
res1 = run_command(['identify', '-format', '%k', added]) | ||
res2 = run_command(['identify', '-format', '%k', removed]) | ||
include = res1 == '2' and res2 == '2' | ||
remove(added) | ||
remove(removed) | ||
return include | ||
|
||
|
||
def create_diff_stat(old_name, new_name, diff_name, font_size, layer, resolution, name_layer, only_different): | ||
wn, hn = png_size(new_name) | ||
wo, ho = png_size(old_name) | ||
|
@@ -527,6 +566,9 @@ def DiffImages(old_file_hash, new_file_hash, layers_old, layers_new, only_differ | |
if args.diff_mode == 'red_green': | ||
inc = create_diff_stereo(old_name, new_name, diff_name, font_size, layer, resolution, name_layer, | ||
only_different) | ||
elif args.diff_mode == '2color': | ||
inc = create_diff_stereo_colored(old_name, new_name, diff_name, font_size, layer, resolution, | ||
name_layer, only_different) | ||
else: | ||
inc = create_diff_stat(old_name, new_name, diff_name, font_size, layer, resolution, name_layer, | ||
only_different) | ||
|
@@ -718,10 +760,11 @@ def get_layer(line): | |
|
||
parser.add_argument('old_file', help='Original file (PCB/SCH)') | ||
parser.add_argument('new_file', help='New file (PCB/SCH)') | ||
parser.add_argument('--added_2color', help='Color used for added stuff in 2color mode', type=str, default='green') | ||
parser.add_argument('--all_pages', help='Compare all the schematic pages', action='store_true') | ||
parser.add_argument('--cache_dir', help='Directory to cache images', type=str) | ||
parser.add_argument('--diff_mode', help='How to compute the image difference [red_green]', | ||
choices=['red_green', 'stats'], default='red_green') | ||
choices=['red_green', 'stats', '2color'], default='red_green') | ||
group = parser.add_mutually_exclusive_group() | ||
group.add_argument('--exclude', help='Exclude layers in file (one layer per line)', type=str) | ||
parser.add_argument('--force_gs', help='Use Ghostscript even when Poppler is available', action='store_true') | ||
|
@@ -740,6 +783,7 @@ def get_layer(line): | |
parser.add_argument('--only_different', help='Only include the pages with differences', action='store_true') | ||
parser.add_argument('--output_dir', help='Directory for the output file', type=str) | ||
parser.add_argument('--output_name', help='Name of the output diff', type=str, default='diff.pdf') | ||
parser.add_argument('--removed_2color', help='Color used for removed stuff in 2color mode', type=str, default='red') | ||
parser.add_argument('--resolution', help='Image resolution in DPIs [%(default)s]', type=int, default=150) | ||
parser.add_argument('--threshold', help='Error threshold for diff stats mode, 0 is no error [%(default)s]', | ||
type=thre_type, default=0, metavar='[0-1000000]') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
__copyright__ = 'Copyright 2020, INTI' | ||
__credits__ = ['Salvador E. Tropea', 'Jesse Vincent'] | ||
__license__ = 'GPL 2.0' | ||
__version__ = '2.5.2' | ||
__version__ = '2.5.3' | ||
__email__ = '[email protected]' | ||
__status__ = 'beta' | ||
__url__ = 'https://github.com/INTI-CMNB/KiDiff/' | ||
|