Package moul :: Package file :: Module kiimage :: Class KIImage
[hide private]
[frames] | no frames]

Class KIImage



object --+
         |
        KIImage

Ki image handler

MOUL's KI images have four leading bytes of junk that encode the file size. The class allowes to add, remove and verify the header.

Instance Methods [hide private]
  __init__(self, fd_name)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  close(self)
Close file handler
  getFileSize(self)
Get size of file
  moulHeaderToSize(self, header=None)
Convert a MOUL header to file size in int
  sizeToMoulHeader(self, size=None)
Converts a file size in int to a MOUL header string
  verifyMoulHeader(self, header=None)
  isJpeg(self)
Check if file is a JPEG image w/o MOUL header
  isMoulImage(self)
Check if file is a MOUL file (JPEG file with MOUL header)
  removeMoulHeader(self)
Remove MOUL header from an image
  addMoulHeader(self)
Add MOUL header to an image

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, fd_name)
(Constructor)

 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__init__
(inherited documentation)

close(self)

 
Close file handler

getFileSize(self)

 

Get size of file

Uses the standard seek(0,2)+tell() syntax to get the size of the file. The file size is cached in self._size. The function resets the position of the file pointer at the end of the call.

moulHeaderToSize(self, header=None)

 

Convert a MOUL header to file size in int

NOTE: A MOUL file is jpeg size + 4 bytes header size

If header is not given the header of the current file is used.

sizeToMoulHeader(self, size=None)

 

Converts a file size in int to a MOUL header string

NOTE: A MOUL file is jpeg size + 4 bytes header size

verifyMoulHeader(self, header=None)

 
None

isJpeg(self)

 

Check if file is a JPEG image w/o MOUL header

The method only checks the header. It doesn't verify the whole file.

isMoulImage(self)

 

Check if file is a MOUL file (JPEG file with MOUL header)

The method only checks the header. It doesn't verify the whole file but it verifies the MOUL header.

removeMoulHeader(self)

 

Remove MOUL header from an image

The method doesn't chance the current file. It returns a file descriptor to a temporary file.

addMoulHeader(self)

 

Add MOUL header to an image

The method doesn't chance the current file. It returns a file descriptor to a temporary file.