;+ ; Contains the summary_to_img procedure ; ; :Author: ; Baptiste Cecconi ; ; :History: ; 2008/10/20: Created ; ; 2014/02/28: Last Edit ;- ; ;+ ; summary_to_img is a procedure that <behavior desc here> ; ; :Params: ; aj1: in, required, type=sometype ; A parameter named aj1 ; aj2: in, required, type=sometype ; A parameter named aj2 ; ; :Keywords: ; verbose: in, optional, type=sometype ; A keyword named verbose ; type: in, optional, type=sometype ; A keyword named type ;- pro summary_to_img,aj1,aj2,verbose=verbose,type=type if keyword_set(verbose) then verbose=1b else verbose=0b if ~keyword_set(type) then type="raw" p = make_file_list(aj1,0,aj2,24,level='pdf',summary_type=type,verbose=verbose) if ptr_valid(p) then begin pdf_list = *p nfiles = n_elements(pdf_list) ptr_free,p endif else begin ptr_free,p nfiles=0 message,/info,'No pdf file for the selected period.' endelse local_path = '~/temp/' if ~file_test(local_path) then spawn,'mkdir '+local_path case type of 'raw' : begin str_offset = 0 end 'SVb' : begin str_offset = 4 end 'SVe' : begin str_offset = 4 end 'LTb' : begin str_offset = 4 end endcase for i=0,nfiles-1 do begin message,/info,'File : '+pdf_list(i) file_path = strmid(pdf_list(i),0,strlen(pdf_list(i))-(str_offset+15)) if ~file_test(file_path+'img/') then spawn,'mkdir '+file_path+'img/' file_name = strmid(pdf_list(i),strlen(pdf_list(i))-(str_offset+11),(str_offset+7)) message,/info,'copying pdf to local tree' spawn_cmd = 'cp '+file_path+'pdf/'+file_name+'.pdf '+local_path+file_name+'.pdf' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd case strmid(type,0,2) of 'ra' : begin message,/info,'converting upper PDF to PNG' spawn_cmd = 'convert -extract 611x192+69+71 '+local_path+file_name+'.pdf '+local_path+file_name+'-1-611x192.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'converting lower PDF to PNG' spawn_cmd = 'convert -extract 611x192+69+320 '+local_path+file_name+'.pdf '+local_path+file_name+'-2-611x192.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd end 'SV' : begin message,/info,'converting upper [S] PDF to PNG' spawn_cmd = 'convert -extract 547x176+109+84 '+local_path+file_name+'.pdf '+local_path+file_name+'-1-547x176.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'resizing [S] PNG' spawn_cmd = 'convert -adaptive-resize 611x192\! '+local_path+file_name+'-1-547x176.png '+local_path+file_name+'-1-611x192.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'converting lower [V] PDF to PNG' spawn_cmd = 'convert -extract 547x176+109+311 '+local_path+file_name+'.pdf '+local_path+file_name+'-2-547x176.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'resizing [V] PNG' spawn_cmd = 'convert -adaptive-resize 611x192\! '+local_path+file_name+'-2-547x176.png '+local_path+file_name+'-2-611x192.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd end 'LT' : begin message,/info,'converting upper [L] PDF to PNG' spawn_cmd = 'convert -extract 547x176+109+84 '+local_path+file_name+'.pdf '+local_path+file_name+'-1-547x176.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'resizing [L] PNG' spawn_cmd = 'convert -adaptive-resize 611x192\! '+local_path+file_name+'-1-547x176.png '+local_path+file_name+'-1-611x192.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'converting lower [T] PDF to PNG' spawn_cmd = 'convert -extract 547x176+109+311 '+local_path+file_name+'.pdf '+local_path+file_name+'-2-547x176.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'resizing [T] PNG' spawn_cmd = 'convert -adaptive-resize 611x192\! '+local_path+file_name+'-2-547x176.png '+local_path+file_name+'-2-611x192.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd end endcase message,/info,'converting PDF to small PNG' spawn_cmd = 'convert -resize 20%x20% -background white -flatten '+local_path+file_name+'.pdf '+local_path+file_name+'-small.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'converting PDF to small JPG' spawn_cmd = 'convert -resize 20%x20% -background white -flatten '+local_path+file_name+'.pdf '+local_path+file_name+'-small.jpg' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd message,/info,'converting PDF to 2-hour extracted PNG' for j=0,1 do for k=0,11 do begin spawn_cmd = 'convert -extract 51x192+'+strtrim(string(51*k),2)+'+0 '+local_path+file_name+'-'+string(format='(I1)',j+1)+'-611x192.png '+local_path+file_name+'-'+string(format='(I1)',j+1)+'-'+string(format='(I2.2)',k*2)+'.png' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd endfor message,/info,'copying img to remote tree' spawn_cmd = 'cp '+local_path+file_name+'-small.jpg '+file_path+'img/' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd spawn_cmd = 'cp '+local_path+file_name+'-small.png '+file_path+'img/' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd for j=0,1 do for k=0,11 do begin spawn_cmd = 'cp '+local_path+file_name+'-'+string(format='(I1)',j+1)+'-'+string(format='(I2.2)',k*2)+'.png '+file_path+'img/' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd endfor message,/info,'removing local files' spawn_cmd = 'rm -rf '+local_path+file_name+'*.png '+local_path+file_name+'*.jpg '+local_path+file_name+'.pdf' if verbose then message,/info,'> '+spawn_cmd spawn,spawn_cmd endfor ; Update the Kronos Database with the new files spawn, [getenv('ROOT_RPWS') + '/pro/kronosdb/upsert.sh', '-l', 'img', string(format='(I7)', aj1), string(format='(I7)', aj2)], /NOSHELL end