<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Creating User Profiles with Image Thumbnails in Django</title>
	<atom:link href="http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 06 Jun 2010 14:51:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Lorenzo</title>
		<link>http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/comment-page-1/#comment-22</link>
		<dc:creator>Lorenzo</dc:creator>
		<pubDate>Mon, 03 May 2010 17:39:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.beardygeek.com/?p=32#comment-22</guid>
		<description>I make use of signals to handle thumb/post processing of images:&lt;br&gt;    from django.db.models.signals import post_save&lt;br&gt;    def image_postprocess(sender, instance=None, created=None, *args, **kwargs):&lt;br&gt;        &quot;&quot;&quot; Image postprocessing &quot;&quot;&quot;&lt;br&gt;        ...&lt;br&gt;    post_save.connect(image_postprocessing, sender=Image)&lt;br&gt;&lt;br&gt;It&#039;s more reusable than overriding the save() method</description>
		<content:encoded><![CDATA[<p>I make use of signals to handle thumb/post processing of images:<br />    from django.db.models.signals import post_save<br />    def image_postprocess(sender, instance=None, created=None, *args, **kwargs):<br />        &#8220;&#8221;" Image postprocessing &#8220;&#8221;"<br />        &#8230;<br />    post_save.connect(image_postprocessing, sender=Image)</p>
<p>It&#39;s more reusable than overriding the save() method</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aaa35</title>
		<link>http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/comment-page-1/#comment-21</link>
		<dc:creator>aaa35</dc:creator>
		<pubDate>Fri, 23 Apr 2010 02:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.beardygeek.com/?p=32#comment-21</guid>
		<description>Good!</description>
		<content:encoded><![CDATA[<p>Good!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: itjobs1</title>
		<link>http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/comment-page-1/#comment-9</link>
		<dc:creator>itjobs1</dc:creator>
		<pubDate>Thu, 03 Dec 2009 20:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.beardygeek.com/?p=32#comment-9</guid>
		<description>Thank you nice post</description>
		<content:encoded><![CDATA[<p>Thank you nice post</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/comment-page-1/#comment-8</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sun, 16 Aug 2009 22:23:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.beardygeek.com/?p=32#comment-8</guid>
		<description>Hi there, great bit of coding you&#039;ve done here. I&#039;ve been trying to follow, but coming across some errors. &lt;br&gt;&lt;br&gt;I&#039;m not entirely sure if my installation is set up properly, or if it&#039;s a problem with the trunk version of Django. &lt;br&gt;&lt;br&gt;When calling self.photo.path in the thumbnail creation, it seems to be getting my MEDIA_ROOT with the filename appended (ignoring any other bits of folder structure that has been set earlier).  The only thing I can think of is if adding the upload_to instruction doesnt get recorded properly.&lt;br&gt;&lt;br&gt;ie. MEDIA_ROOT/filename.jpg&lt;br&gt;&lt;br&gt;Any thoughts? Feel free to drop me an email.</description>
		<content:encoded><![CDATA[<p>Hi there, great bit of coding you&#39;ve done here. I&#39;ve been trying to follow, but coming across some errors. </p>
<p>I&#39;m not entirely sure if my installation is set up properly, or if it&#39;s a problem with the trunk version of Django. </p>
<p>When calling self.photo.path in the thumbnail creation, it seems to be getting my MEDIA_ROOT with the filename appended (ignoring any other bits of folder structure that has been set earlier).  The only thing I can think of is if adding the upload_to instruction doesnt get recorded properly.</p>
<p>ie. MEDIA_ROOT/filename.jpg</p>
<p>Any thoughts? Feel free to drop me an email.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliland</title>
		<link>http://www.beardygeek.com/2008/11/creating-user-profiles-with-image-thumbnails-in-django/comment-page-1/#comment-7</link>
		<dc:creator>Oliland</dc:creator>
		<pubDate>Thu, 16 Jul 2009 04:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.beardygeek.com/?p=32#comment-7</guid>
		<description>Fixed that for you &lt;br&gt;&lt;br&gt;    def save(self, force_insert=False, force_update=False):&lt;br&gt;        import os&lt;br&gt;        #get mtime stats from file&lt;br&gt;        thumb_update = False&lt;br&gt;&lt;br&gt;        # Does a thumbnail exist?&lt;br&gt;        if self.thumbnail:&lt;br&gt;            # Does it actually exist?&lt;br&gt;            try:&lt;br&gt;                # If so, compare it to the latest photo&lt;br&gt;                statinfo1 = os.stat(self.photo.path)&lt;br&gt;                statinfo2 = os.stat(self.thumbnail.path)&lt;br&gt;                if statinfo1 &gt; statinfo2:&lt;br&gt;                    thumb_update = True&lt;br&gt;            # If not, update the thumbnail&lt;br&gt;            except OSError:&lt;br&gt;                thumb_update = True&lt;br&gt;&lt;br&gt;        if self.photo and not self.thumbnail or thumb_update:&lt;br&gt;            from PIL import Image&lt;br&gt;&lt;br&gt;            THUMB_SIZE = (150, 150)&lt;br&gt;&lt;br&gt;            #self.thumbnail = self.photo&lt;br&gt;&lt;br&gt;            image = Image.open(self.photo.path)&lt;br&gt;&lt;br&gt;            if image.mode not in (&#039;L&#039;, &#039;RGB&#039;):&lt;br&gt;                image = image.convert(&#039;RGB&#039;)&lt;br&gt;&lt;br&gt;            image.thumbnail(THUMB_SIZE, Image.ANTIALIAS)&lt;br&gt;            (head, tail) = os.path.split(self.photo.path)&lt;br&gt;            (a, b) = os.path.split(self.photo.name)&lt;br&gt;&lt;br&gt;            if not os.path.isdir(head + &#039;/thumbs&#039;):&lt;br&gt;                os.mkdir(head + &#039;/thumbs&#039;)&lt;br&gt;&lt;br&gt;            image.save(head + &#039;/thumbs/&#039; + tail)&lt;br&gt;&lt;br&gt;            self.thumbnail = a + &#039;/thumbs/&#039; + b&lt;br&gt;&lt;br&gt;        super(UserProfile, self).save()</description>
		<content:encoded><![CDATA[<p>Fixed that for you </p>
<p>    def save(self, force_insert=False, force_update=False):<br />        import os<br />        #get mtime stats from file<br />        thumb_update = False</p>
<p>        # Does a thumbnail exist?<br />        if self.thumbnail:<br />            # Does it actually exist?<br />            try:<br />                # If so, compare it to the latest photo<br />                statinfo1 = os.stat(self.photo.path)<br />                statinfo2 = os.stat(self.thumbnail.path)<br />                if statinfo1 &gt; statinfo2:<br />                    thumb_update = True<br />            # If not, update the thumbnail<br />            except OSError:<br />                thumb_update = True</p>
<p>        if self.photo and not self.thumbnail or thumb_update:<br />            from PIL import Image</p>
<p>            THUMB_SIZE = (150, 150)</p>
<p>            #self.thumbnail = self.photo</p>
<p>            image = Image.open(self.photo.path)</p>
<p>            if image.mode not in (&#39;L&#39;, &#39;RGB&#39;):<br />                image = image.convert(&#39;RGB&#39;)</p>
<p>            image.thumbnail(THUMB_SIZE, Image.ANTIALIAS)<br />            (head, tail) = os.path.split(self.photo.path)<br />            (a, b) = os.path.split(self.photo.name)</p>
<p>            if not os.path.isdir(head + &#39;/thumbs&#39;):<br />                os.mkdir(head + &#39;/thumbs&#39;)</p>
<p>            image.save(head + &#39;/thumbs/&#39; + tail)</p>
<p>            self.thumbnail = a + &#39;/thumbs/&#39; + b</p>
<p>        super(UserProfile, self).save()</p>
]]></content:encoded>
	</item>
</channel>
</rss>
