Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The 2M figure is for a compressed JPEG image, but uncompressed, 3600 x 2700 truecolor will be about 38M (9,720,000 pixels at 4B per pixel), close to the memory usage increase you are experiencing.</p> <p>This is a known problem with PIL, I can produce a pixel bomb by sending you a 40000x40000 pixel black picture as a png. Always check the resolution before loading (or protect the code with a try/except block handling OutOfMemory). See if using im.tile attribute to process the image chunk by chunk gives you a lower memory footprint.</p> <p>May be worth checking:</p> <ul> <li><a href="http://pypi.python.org/pypi/django-image-cropping" rel="nofollow">django-image-cropping</a></li> <li><a href="http://thumbnail.sorl.net/" rel="nofollow">sorl-thumbnail</a></li> </ul> <p>Some alternatives that are said to better handle memory when dealing with larger images:</p> <ul> <li><a href="http://www.gdal.org/" rel="nofollow">GDAL</a> (Geospatial Data Abstraction Library)</li> <li><a href="http://openimageio.org/" rel="nofollow">OIIO</a> (OpenImageIO)</li> <li><a href="http://packages.python.org/mahotas/index.html" rel="nofollow">Mahotas</a> (NumPy)</li> </ul> <p>[ update ]</p> <blockquote> <p>Do you know if there's a way in PIL to release the objects from memory? Because in theory that would be best for this view as I need it to work like it does, but just handle the image better.</p> </blockquote> <ul> <li>In order to avoid memory spikes you can detect huge images and try to process them in chunks using <code>im.tile</code> instead of <code>im.crop</code> (unfortunatelly operating at a lower level).</li> <li>You can delete the intermediate image objects as soon as possible in order to get shorter spikes (using the <a href="http://docs.python.org/library/gc.html" rel="nofollow">gc module</a> you can force the garbage collector to cleanup). </li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload