@@ -160,23 +160,28 @@ def autoingest(self):
160160 inputFiles = self .AutoTools .folderlist ('Ingest' )
161161 outputFiles = self .AutoTools .folderlist ('Ingested' )
162162 outputFiles = self .AutoTools .namestrip (outputFiles , 1 )
163- self .log (outputFiles ,1 )
164163 todoFiles = list (set (inputFiles ) - set (outputFiles ))
165- self .log (todoFiles , 1 )
166164 processes = set ()
167165 max_processes = 4
168166 for F in todoFiles :
169- self .log ('Splitting ' + F + ":\n Prossesing Right..." )
170- FoutR = F [:8 ] + "R" + F [- 4 :]
171- FoutL = F [:8 ] + "L" + F [- 4 :]
172- # Offset of half the image
173- # TODO: Make a option for this read the image dimennsions from the metadata using PIL
174- args = 'convert "' + './Ingest/' + F + '"' + " -crop 3888x3888+0+0 " + '"' + './Ingested/' + FoutR + '"'
175- self .AutoTools .command (args )
176- self .log ('Prossesing Left...' )
177- # Image full size is 7776 wide and 3888 tall. (easy right?)
178- args = 'convert "' + './Ingest/' + F + '"' + " -crop 3888x3888+3888+0 " + '"' + './Ingested/' + FoutL + '"'
179- self .AutoTools .command (args )
167+ # Now reads image metadata to get the dimensions.
168+ origWidth , origHeight = Image .open ("./Ingest/" + F ).size
169+ if (origWidth == (origHeight * 2 )):
170+ origHeight = str (origHeight )
171+ origWidth = str (origWidth )
172+ self .log ('Splitting ' + F + ":\n Prossesing Right..." )
173+ FoutR = F [:8 ] + "R" + F [- 4 :]
174+ FoutL = F [:8 ] + "L" + F [- 4 :]
175+ crop = origHeight + 'x' + origHeight + '+0+0'
176+ args = 'convert "' + './Ingest/' + F + '" -crop ' + crop + ' "' + './Ingested/' + FoutR + '"'
177+ self .AutoTools .command (args )
178+ self .log ('Prossesing Left...' )
179+ # Offset of half the image
180+ crop = origHeight + 'x' + origHeight + '+' + origHeight + '+0'
181+ args = 'convert "' + './Ingest/' + F + '" -crop ' + crop + ' "' + './Ingested/' + FoutL + '"'
182+ self .AutoTools .command (args )
183+ else :
184+ self .log ("Image '" + F + "' is not 2:1 aspect ratio, Skipping." )
180185 self .AutoTools .processesWait (0 )
181186 self .log ('All files split.' )
182187
0 commit comments