core.files.images.ImageFile

class ImageFile(file_object) [source] Django provides a built-in class specifically for images. django.core.files.images.ImageFile inherits all the attributes and methods of File, and additionally provides the following: width Width of the image in pixels. height Height of the image in pixels.

core.files.images.ImageFile.height

height Height of the image in pixels.

core.files.File.__iter__()

__iter__() [source] Iterate over the file yielding one line at a time.

core.files.File.save()

File.save(name, content, save=True) Saves a new file with the file name and contents provided. This will not replace the existing file, but will create a new file and update the object to point to it. If save is True, the model’s save() method will be called once the file is saved. That is, these two lines: >>> car.photo.save('myphoto.jpg', content, save=False) >>> car.save() are equivalent to: >>> car.photo.save('myphoto.jpg', content, save=True) Note that the c

core.files.File.read()

read(num_bytes=None) Read content from the file. The optional size is the number of bytes to read; if not specified, the file will be read to the end.

core.files.File.size

size The size of the file in bytes.

core.files.File.write()

write(content) Writes the specified content string to the file. Depending on the storage system behind the scenes, this content might not be fully committed until close() is called on the file.

core.files.File.name

name The name of the file including the relative path from MEDIA_ROOT.

core.files.File.open()

open(mode=None) [source] Open or reopen the file (which also does File.seek(0)). The mode argument allows the same values as Python’s built-in open(). When reopening a file, mode will override whatever mode the file was originally opened with; None means to reopen with the original mode.

core.files.File.multiple_chunks()

multiple_chunks(chunk_size=None) [source] Returns True if the file is large enough to require multiple chunks to access all of its content give some chunk_size.