
    
3j	                         S r SrSrSSKJr  SSKJrJr  SSK7  SSK	r	SSK
r
SSKrS rS	 rS
 r\S:X  a  \
R                   " \" 5       5        gg)zChristopher Hahnezinfo@christopherhahne.dea  
    Copyright (c) 2020 Christopher Hahne <info@christopherhahne.de>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    )__version__)ColorMatcherMETHODS)*Nc            
      .   [        S5        [        S5        [        S5        [        S5        [        S5        [        SSR                  [         V s/ s H  n SU -   S-   PM     sn 5      -   5        [        S	5        [        S
5        [        S5        g s  sn f )NzUsage: color-matcher <options>
zOptions:zP-s <path>,     --src=<path>       Specify source image file or folder to processz;-r <filepath>, --ref=<filepath>   Specify target image filezH-m <method>,   --method=<method>  Provide color transfer method such as:z"                                  z, "z:-w ,           --win              Select files from windowz9-h,            --help             Print this help message )printjoinr   )ms    J/home/wildlama/miniconda3/lib/python3.13/site-packages/../../../bin/cli.pyusager      s{    	
,-	*	
\]	
GH	
TU	
.tyyW9UW#a%)W9U/V
VW	
FG	
EF	"I :Vs   Bc                 2    [         R                   " U S/ SQ5      u  p[        5       nSUS'   SUS'   [        S   US'   S US	'   W(       a  U H  u  pVUS
;   a  [        5         [        R                  " 5         US;   a  UR                  S5      US'   US;   a  UR                  S5      US'   US;   a  UR                  S5      US'   US;   d  M  SUS	'   M     U$ ! [         R                   a+  n[        U5        [        R                  " S5         S nANS nAff = f)Nzhs:r:m:w)helpzsrc=zref=zmethod=win   .src_pathref_pathr   methodr   )z-hz--help)z-sz--srcz "')z-rz--ref)z-mz--method)z-wz--winT)	getoptGetoptErrorr
   sysexitdictr   r   strip)argvoptsargsecfgoptargs          r   parse_optionsr$   ,   s   ]]45_`
 &C C
OC
OAJCMCJJS&&
o%"%))G"4Jo%"%))G"4J(( #		' 2Ho%!E
  J7  as   C D+!DDc            	      :   [        S[        -  5        [        [        R                  SS  5      n U S   (       a$  [        U S   S5      U S'   [        U S   S5      U S'   U S   (       a
  U S   (       d*  [        5         [        S5        [        R                  " 5         [        R                  R                  U S   5      (       Ga.  [        R                  R                  U S   5      (       Ga  [        R                  " U S   5       Vs/ s HP  nUR                  5       R                  [        5      (       d  M-  [        R                  R!                  U S   U5      PMR     nn[        R                  R!                  U S   S	[#        U S
   5      -   5      n[        R$                  " USS9  [        S[        R                  R!                  S[        R                  R'                  U5      5      -  5        GO5[        R                  R                  U S   5      (       a  [        R                  R                  U S   5      (       a  U S   /n[        R                  R)                  U S   5      n[        R                  R+                  [        R                  R'                  U S   5      5      S   S-   U S
   -   n[        R                  R+                  U S   5      S   n[        S[        R                  R!                  SXE-   5      -  5        O [        S5        [        R                  " 5         U S
   [,        ;   a  U S
   O[,        S   U S
'   [/        U S   5      nW H  n[/        U5      n[1        XvU S
   S9R3                  5       n[        R                  R+                  [        R                  R'                  U5      5      S   S-   U S
   -   n[        R                  R+                  U5      S   n[5        U[        R                  R!                  WU5      USS  S9  M     gs  snf )Nz
color-matcher v%s 
   r   r   zSelect source imagezSelect reference imager   z(Canceled due to missing image file path
batch_proc_r   T)exist_okz/Output files are placed in created directory %sr   r   _zOutput file is named %szFile(s) not found 
)srcrefr   )	file_path	file_type)r
   r   r$   r   r   select_filer   r   ospathisdirisfilelistdirlowerendswith	FILE_EXTSr   strmakedirsbasenamedirnamesplitextr   load_img_filer   mainsave_img_file)	r!   f	filenamesoutput_pathfilenamefile_extr,   r+   ress	            r   r>   r>   N   s    

"[
01 
%C 5z%c*o7LMJ%c*o7OPJ z?#j/9:
 
ww}}S_%%"''..Z*I*I?Azz#j/?Z 7?Z!	**95 6RWW\\#j/15?Z	 7ggll3z?M#c(mBT4TU
K$/?"'',,sTVT[T[TdTdepTqBrrs	J	(	(RWW^^C
O-L-L_%	ggooc*o677##BGG$4$4S_$EFqI#McRZm[77##C
O4R8'"'',,sH<O*PPQ 	$%
 &)]g%=CM71:CM J
(C AsCMBGGI77##BGG$4$4Q$78;C?HM77##A&r*cRWW\\+x%HT\]^]_T`a  ?7s   ,P6'P__main__)
__author__	__email____license__color_matcherr   color_matcher.top_levelr   r   color_matcher.io_handlerr   r   r0   r   r$   r>   __name__r        r   <module>rP      sW    !
&	$ & 9 &  
D5p zHHTV rO   