aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-11-12 15:12:39 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-11-12 15:12:39 -0600
commitd0504cfa875b0ac7340fb00a64fc8422faecdc9a (patch)
treeb8028a058197aa61ca069db9ecfc09ae94460b28
parent0cf5b8ad2499a93fdba5ff1202fdc554208ec85f (diff)
downloadmediagoblin-d0504cfa875b0ac7340fb00a64fc8422faecdc9a.tar.lz
mediagoblin-d0504cfa875b0ac7340fb00a64fc8422faecdc9a.tar.xz
mediagoblin-d0504cfa875b0ac7340fb00a64fc8422faecdc9a.zip
Final step for non-force-conversion to jpeg
-rw-r--r--mediagoblin/process_media/__init__.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/mediagoblin/process_media/__init__.py b/mediagoblin/process_media/__init__.py
index 85bdcbea..f63fb2b0 100644
--- a/mediagoblin/process_media/__init__.py
+++ b/mediagoblin/process_media/__init__.py
@@ -14,8 +14,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import Image
+import os
+import Image
from celery.task import Task
from celery import registry
@@ -122,17 +123,16 @@ def process_image(entry):
mgg.queue_store, queued_filepath,
'source')
+ extension = os.path.splitext(queued_filename)[1]
+
try:
thumb = Image.open(queued_filename)
except IOError:
raise BadMediaFail()
thumb.thumbnail(THUMB_SIZE, Image.ANTIALIAS)
- # ensure color mode is compatible with jpg
- if thumb.mode != "RGB":
- thumb = thumb.convert("RGB")
- thumb_filepath = create_pub_filepath(entry, 'thumbnail.jpg')
+ thumb_filepath = create_pub_filepath(entry, 'thumbnail' + extension)
thumb_file = mgg.public_store.get_file(thumb_filepath, 'w')
with thumb_file:
@@ -147,10 +147,7 @@ def process_image(entry):
if medium.size[0] > MEDIUM_SIZE[0] or medium.size[1] > MEDIUM_SIZE[1]:
medium.thumbnail(MEDIUM_SIZE, Image.ANTIALIAS)
- if medium.mode != "RGB":
- medium = medium.convert("RGB")
-
- medium_filepath = create_pub_filepath(entry, 'medium.jpg')
+ medium_filepath = create_pub_filepath(entry, 'medium' + extension)
medium_file = mgg.public_store.get_file(medium_filepath, 'w')
with medium_file: