@ -28,9 +28,9 @@ var site_names = csv_data.toString().split(",")
/ / R e t r i e v e i m a g e s p a r e n t d i r e c t o r y f r o m C o a s t S n a p _ S i t e s . c s v
/ / R e t r i e v e i m a g e s p a r e n t d i r e c t o r y f r o m C o a s t S n a p _ S i t e s . c s v
var parent _folder _path = File ( site _names [ 9 ] ) ;
var parent _folder _path = File ( site _names [ 9 ] ) ;
var batch _images _to _register = [ ] ; / / U s e d i n e x p o r t L a y e r s T o J P E G
var batch _images _to _register = [ ] ; / / U s e d i n e x p o r t L a y e r s T o J P E G
/ / L o o p t h r o u g h s i t e s
/ / L o o p t h r o u g h s i t e s
for ( var i = 5 ; i < site_names.length ; i + = 5 ) {
for ( var i = 5 ; i < site_names.length ; i + = 5 ) {
var site _name = site _names [ i ] ;
var site _name = site _names [ i ] ;
@ -63,9 +63,12 @@ for(var i=5; i<site_names.length; i+=5) {
for ( var k = 0 ; k < images _to _register . length ; k += batch _size ) {
for ( var k = 0 ; k < images _to _register . length ; k += batch _size ) {
batch _register _images ( k , site _path , site _name , images _to _register , target _image , seed _images ) ;
batch _register _images ( k , site _path , site _name , images _to _register , target _image , seed _images ) ;
}
}
}
}
}
}
/ / C l o s e P h o t o s h o p
executeAction ( app . charIDToTypeID ( 'quit' ) , undefined , DialogModes . NO ) ;
/ / T h i s i s t h e m a i n f u n c t i o n , r e s p o n s i b l e f o r c a l l i n g p h o t o s h o p f u n c t i o n s
/ / T h i s i s t h e m a i n f u n c t i o n , r e s p o n s i b l e f o r c a l l i n g p h o t o s h o p f u n c t i o n s
/ / i n a s e q u e n t i a l o r d e r t o r e g i s t e r a l l _ i m a g e s
/ / i n a s e q u e n t i a l o r d e r t o r e g i s t e r a l l _ i m a g e s
@ -100,6 +103,7 @@ function batch_register_images(batchIndex, site_path, site_name, images_to_regis
exportLayersToJPEG ( target _width , target _height , batch _images _to _register , seed _images ) ; / / W o n ' t o v e r w r i t e i m a g e s t h a t a l r e a d y e x i s t
exportLayersToJPEG ( target _width , target _height , batch _images _to _register , seed _images ) ; / / W o n ' t o v e r w r i t e i m a g e s t h a t a l r e a d y e x i s t
app . activeDocument . close ( SaveOptions . DONOTSAVECHANGES )
app . activeDocument . close ( SaveOptions . DONOTSAVECHANGES )
purgeCache ( ) ; / / T o h e l p a v o i d t h e s c r a t c h d i s k f r o m b e c o m i n g f u l l
}
}
@ -111,13 +115,19 @@ function imagesNotRegistered(site_images_all, photoshop_images) {
for ( var i = 0 ; i < site _images _all . length ; i ++ ) { / / F o r e a c h s i t e i m a g e
for ( var i = 0 ; i < site _images _all . length ; i ++ ) { / / F o r e a c h s i t e i m a g e
var isRegistered = false ;
var isRegistered = false ;
for ( var j = 0 ; j < photoshop _images . length ; j ++ ) { / / C h e c k i f a l r e a d y e x i s t s i n p h o t o s h o p i m a g e s
for ( var j = 0 ; j < photoshop _images . length ; j ++ ) { / / C h e c k i f a l r e a d y e x i s t s i n p h o t o s h o p i m a g e s
var site _name _CHECK = site _images _all [ i ] . name . slice ( 0 , - 4 ) + '_CHECK.jpg' ;
/ / v a r s i t e _ n a m e _ C H E C K = s i t e _ i m a g e s _ a l l [ i ] . n a m e . s l i c e ( 0 , - 4 ) + ' _ C H E C K . j p g ' ;
if ( ( site _images _all [ i ] . name . toString ( ) == photoshop _images [ j ] . name . toString ( ) ) || ( site _name _CHECK . toString ( ) == photoshop _images [ j ] . name . toString ( ) ) ) {
var site _image = site _images _all [ i ] . name . toString ( )
site _image = site _image . replace ( "%20" , "_" )
if ( ( site _image == photoshop _images [ j ] . name . toString ( ) ) ) {
isRegistered = true ;
isRegistered = true ;
break ;
break ;
}
}
}
}
if ( ! isRegistered ) { / / I f i t d o e s n ' t , r e g i s t e r i t
if ( ! isRegistered ) { / / I f i t d o e s n ' t , r e g i s t e r i t
/ / s i t e 2 a d d = s i t e _ i m a g e s _ a l l [ i ] . t o S t r i n g ( )
/ / v a r s = s i t e 2 a d d . r e p l a c e ( " % 2 0 " , " _ " ) / / g e t F i l e s ( ) r e a d s i n w h i t e s p a c e a s " % 2 0 " . S o c o n v e r t t o " _ "
/ / a l e r t ( s )
/ / v a r s = F i l e ( s i t e _ i m a g e ) ;
site _images . push ( site _images _all [ i ] ) ;
site _images . push ( site _images _all [ i ] ) ;
}
}
}
}
@ -287,7 +297,10 @@ function exportLayersToJPEG(target_width, target_height, batch_images_to_registe
/ / }
/ / }
for ( var i = 0 ; i < batch _images _to _register . length ; i ++ ) { / / L o o p t h r o u g h b a t c h _ i m a g e s _ t o _ r e g i s t e r
for ( var i = 0 ; i < batch _images _to _register . length ; i ++ ) { / / L o o p t h r o u g h b a t c h _ i m a g e s _ t o _ r e g i s t e r
if ( batch _images _to _register [ i ] . toString ( ) == name . toString ( ) ) {
var image2register = batch _images _to _register [ i ] . toString ( ) ;
image2register = image2register . replace ( "%20" , " " )
if ( image2register == name . toString ( ) ) {
app . activeDocument . activeLayer = el . layers . getByName ( name ) ;
app . activeDocument . activeLayer = el . layers . getByName ( name ) ;
var theBounds = app . activeDocument . activeLayer . bounds ;
var theBounds = app . activeDocument . activeLayer . bounds ;
@ -316,7 +329,10 @@ function exportLayersToJPEG(target_width, target_height, batch_images_to_registe
activeDocument . mergeVisibleLayers ( ) ;
activeDocument . mergeVisibleLayers ( ) ;
}
}
/ / a c t i v e D o c u m e n t . t r i m ( T r i m T y p e . T R A N S P A R E N T , t r u e , t r u e , t r u e , t r u e ) ;
/ / a c t i v e D o c u m e n t . t r i m ( T r i m T y p e . T R A N S P A R E N T , t r u e , t r u e , t r u e , t r u e ) ;
var saveFile = File ( path + "/Photoshop/" + year + "/" + lname ) ;
output _file _path = path + "/Photoshop/" + year + "/" + lname ;
output _file _path = output _file _path . replace ( " " , "_" )
var saveFile = File ( output _file _path ) ;
SaveJPEG ( saveFile ) ;
SaveJPEG ( saveFile ) ;
app . activeDocument . close ( SaveOptions . DONOTSAVECHANGES ) ;
app . activeDocument . close ( SaveOptions . DONOTSAVECHANGES ) ;
}
}
@ -343,3 +359,15 @@ function SaveJPEG(saveFile){
pngOpts . quality = 100 ;
pngOpts . quality = 100 ;
activeDocument . exportDocument ( new File ( saveFile ) , ExportType . SAVEFORWEB , pngOpts ) ;
activeDocument . exportDocument ( new File ( saveFile ) , ExportType . SAVEFORWEB , pngOpts ) ;
}
}
/ / N o t s u r e i f t h i s d o e s a n y t h i n g
function purgeCache ( ) {
var idPrge = charIDToTypeID ( "Prge" ) ;
var desc335 = new ActionDescriptor ( ) ;
var idnull = charIDToTypeID ( "null" ) ;
var idPrgI = charIDToTypeID ( "PrgI" ) ;
var idClpb = charIDToTypeID ( "Clpb" ) ;
desc335 . putEnumerated ( idnull , idPrgI , idClpb ) ;
executeAction ( idPrge , desc335 , DialogModes . NO ) ;
}