Server IP : 127.0.0.2 / Your IP : 3.15.2.88 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python2.7/dist-packages/PIL/ |
Upload File : |
# # The Python Imaging Library. # $Id$ # # DCX file handling # # DCX is a container file format defined by Intel, commonly used # for fax applications. Each DCX file consists of a directory # (a list of file offsets) followed by a set of (usually 1-bit) # PCX files. # # History: # 1995-09-09 fl Created # 1996-03-20 fl Properly derived from PcxImageFile. # 1998-07-15 fl Renamed offset attribute to avoid name clash # 2002-07-30 fl Fixed file handling # # Copyright (c) 1997-98 by Secret Labs AB. # Copyright (c) 1995-96 by Fredrik Lundh. # # See the README file for information on usage and redistribution. # from PIL import Image, _binary from PIL.PcxImagePlugin import PcxImageFile __version__ = "0.2" MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then? i32 = _binary.i32le def _accept(prefix): return len(prefix) >= 4 and i32(prefix) == MAGIC ## # Image plugin for the Intel DCX format. class DcxImageFile(PcxImageFile): format = "DCX" format_description = "Intel DCX" def _open(self): # Header s = self.fp.read(4) if i32(s) != MAGIC: raise SyntaxError("not a DCX file") # Component directory self._offset = [] for i in range(1024): offset = i32(self.fp.read(4)) if not offset: break self._offset.append(offset) self.__fp = self.fp self.seek(0) @property def n_frames(self): return len(self._offset) @property def is_animated(self): return len(self._offset) > 1 def seek(self, frame): if frame >= len(self._offset): raise EOFError("attempt to seek outside DCX directory") self.frame = frame self.fp = self.__fp self.fp.seek(self._offset[frame]) PcxImageFile._open(self) def tell(self): return self.frame Image.register_open(DcxImageFile.format, DcxImageFile, _accept) Image.register_extension(DcxImageFile.format, ".dcx")