Logo Search packages:      
Sourcecode: rapid-photo-downloader version File versions  Download package

def rapid::dropshadow::DropShadow::dropShadow (   self,
  image 
)

image             - The image to overlay on top of the shadow.

Definition at line 96 of file dropshadow.py.

00096                                :
        """
        image             - The image to overlay on top of the shadow.
        """
        dimensions = (image.size[0], image.size[1])
        if not dimensions in self.backgrounds:
            
            # Create the backdrop image -- a box in the background colour with a 
            # shadow on it.
            
            if self.trim_border:
                totalWidth = image.size[0] + abs(self.offset[0]) + self.border
                totalHeight = image.size[1] + abs(self.offset[1]) + self.border
            else:
                totalWidth = image.size[0] + abs(self.offset[0]) + 2 * self.border
                totalHeight = image.size[1] + abs(self.offset[1]) + 2 * self.border
                
            back = Image.new("RGBA", (totalWidth, totalHeight), self.background_color)
            
            # Place the shadow, taking into account the offset from the image
            if self.offset[0] > 0 and self.trim_border:
                shadowLeft = max(self.offset[0], 0)
            else:
                shadowLeft = self.border + max(self.offset[0], 0)
            if self.offset[1] > 0 and self.trim_border:
                shadowTop = max(self.offset[1], 0)
            else:
                shadowTop = self.border + max(self.offset[1], 0)
            
            back.paste(self.shadow, [shadowLeft, shadowTop, shadowLeft + image.size[0], 
                shadowTop + image.size[1]] )
            
            # Apply the filter to blur the edges of the shadow.    Since a small kernel
            # is used, the filter must be applied repeatedly to get a decent blur.
            n = 0
            while n < self.iterations:
                back = back.filter(ImageFilter.BLUR)
                n += 1
                
            self.backgrounds[dimensions] = back
        
        # Paste the input image onto the shadow backdrop                
        imageLeft = self.left_spacing - min(self.offset[0], 0)
        imageTop = self.top_spacing - min(self.offset[1], 0)
            
        back = self.backgrounds[dimensions].copy()
        back.paste(image, (imageLeft, imageTop))
    
        return back
        

    
if __name__ == "__main__":


Generated by  Doxygen 1.6.0   Back to index