1. Álvaro Justen - Turicas
  2. strobo

Commits

Álvaro Justen  committed d22ef4f

Remove some unnecessary blank spaces

  • Participants
  • Parent commits c276bf8
  • Branches default

Comments (0)

Files changed (2)

File strobo.py

View file
  • Ignore whitespace
 class ImageText(Image.Image):
     '''Get a text and create an image with that text.
     '''
-    
-    
+
+
     def __init__(self, mode='RGBA', size=(320, 240),
                  background_color=(255, 255, 255)):
         Image.Image.__init__(self)
         self.size = im.size
         if im.mode == 'P':
             self.palette = ImagePalette.ImagePalette()
-   
-    
+
+
     def write_text(self, (x, y), text, fontfile='DejaVuSansMono.ttf', size=20):
         w_max, h_max = self.size
         draw = ImageDraw.Draw(self)
         self.w = width
         self.h = height
         self.frames = []
-    
-    
+
+
     def add_image(self, image, duration, fade_in=0, fade_out=0, blank_in=None,
                   blank_out=None):
         self.frames.append({'filename': image, 'duration': duration,
             self.frames[-1]['blank_in'] = blank_in
         if blank_out != None:
             self.frames[-1]['blank_out'] = blank_out
-    
-    
+
+
     def create_images(self, path):
         self.path = path
         blank = Image.new('RGBA', (self.w, self.h), color='#FFFFFF')
         blank.save('/tmp/blank.png')
         del(blank)
         blank_in = blank_out = Image.open('/tmp/blank.png')
-        
+
         count = 1
         self.total_duration = 0
         for img in self.frames:
                     #img_tmp.save(img['blank_out'])
                     #del(img_tmp)
                     #img['blank_out'] = Image.open(img['blank_out'])
-            
+
             image = Image.open(img['filename'])
             image = image.convert('RGBA')
             if img['fade_in'] > 0:
                     img_tmp.save('%s/%09d.jpg' % (path, count),
                                  quality=DEFAULT_IMAGE_QUALITY)
                     count += 1
-            
+
             duration_total_frames = int(ceil(img['duration'] * self.fps))
             for f in range(1, duration_total_frames + 1):
                 copyfile(img['filename'], '%s/%09d.jpg' % (path, count))
                 count += 1
-            
+
             if img['fade_out'] > 0:
                 fade_out_total_frames = int(ceil(img['fade_out'] * self.fps))
                 for f in range(1, fade_out_total_frames + 1):
                     img_tmp.save('%s/%09d.jpg' % (path, count),
                                  quality=DEFAULT_IMAGE_QUALITY)
                     count += 1
-            
+
             self.total_duration += img['fade_in'] + img['duration'] + \
                                    img['fade_out']
             self.total_frames = count - 1
-    
-    
+
+
     def render(self, filename_full, audio=None, with_blank_audio=False,
                delete_temp_files=False):
         if with_blank_audio:
             wav.writeframes(chr(128) * total_frames)
             wav.close()
             audio = '/tmp/blank.wav'
-        
+
         filenames = '%s/%%09d.jpg' % self.path
         filename = filename_full.split('/')[-1]
-        
+
         if audio:
             commands = '' \
             '/usr/bin/ffmpeg2theora -v %(video_quality)d --inputfps %(fps)d %(path)s/%%09d.jpg -o /tmp/%(filename)s-video.ogg;' \
                 '/usr/bin/ffmpeg2theora -v %(video_quality)d %(path)s/%%09d.jpg -o %(filename_full)s.ogv' % \
                 dict(video_quality=DEFAULT_VIDEO_QUALITY, path=self.path,
                      filename_full=filename_full)
-        
+
         for cmd in commands.split(';'):
             #TODO: should use logging
             #print 'Executing: '
         #       --copyright           Copyright.
         #       --license             License.
         #       --contact             Contact link.
-        
+
         if delete_temp_files:
             rmtree(self.dirname_frames)
             rmtree(self.dirname)
         self.audio = None
         self.fade_in = fade_in
         self.fade_out = fade_out
-    
-    
+
+
     def add_audio(self, audio):
         self.audio = audio
-    
-    
+
+
     def add_images(self, *args):
         list_of_files = []
         for i in args:
                                blank_in=previous, fade_out=self.fade_out,
                                blank_out='/tmp/black.png')
             previous = image
-    
-    
+
+
     def create_images(self):
         Timeline.create_images(self, self.dirname_frames)
-    
+
 
     def render(self, filename):
         if self.audio:

File test_simple_image_from_text.py

View file
  • Ignore whitespace
 import shutil
 import time
 
+
 print 'Creating image...'
 start = time.time()
 image = ImageText(size=(800, 600), background_color='#FFFFFF')
               (tamanho2, u'Álvaro Justen - Turicas'),
               (tamanho, 'http://blog.justen.eng.br/'),
 ]
-image.write_text((None, 20), image_text)
+image.write_text((0, 20), image_text)
 image.save('dojo_intro.png')
 duration = time.time() - start
 print 'Done in %f seconds' % duration