Logo Search packages:      
Sourcecode: zope-cmfphoto version File versions  Download package

def CMFPhoto::Photo::Photo::callConvert (   self,
  img_file_obj,
  args,
  kwargs 
)

Convert an image using the 'convert' program
img_file_obj is a StringIO instance

Definition at line 368 of file Photo.py.

00368                                                         :
        """
        Convert an image using the 'convert' program
        img_file_obj is a StringIO instance
        """

        command = "convert -quality %s" % DEFAULT_QUALITY
        # TODO check convert manual for argument precedence
        for arg in args:
            command += " -%s " % (arg,)
        for key, val in kwargs.items():
            command += " -%s %s " % (key, val)

        command += " - -" # stdin & stdout as input & output

        if sys.platform == 'win32':
            from win32pipe import popen2
            imgin, imgout = popen2(command, 'b')
        else:
            from popen2 import Popen3
            convert=Popen3(command)
            imgout=convert.fromchild
            imgin=convert.tochild

        imgin.write(str(self.data))
        imgin.close()
        img_file_obj.write(imgout.read())
        imgout.close()

        #Wait for process to close if unix. Should check returnvalue for wait
        if sys.platform !='win32':
            convert.wait()

        img_file_obj.seek(0)
        return img_file_obj

    security.declarePrivate('update_data')
    def update_data(self, data, content_type=None, size=None):


Generated by  Doxygen 1.6.0   Back to index