Skip to content

Commit

Permalink
Added image_data_as_rgb to engine
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarsa committed Mar 19, 2014
1 parent 8c709b8 commit 979bcd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion graphicsmagick_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
try:
from graphicsmagick_engine.engine import Engine # NOQA
except ImportError:
logging.warning('Could not import graphicsmagick_engine. Probably due to setup.py installing it.')
logging.exception('Could not import graphicsmagick_engine. Probably due to setup.py installing it.')
10 changes: 7 additions & 3 deletions graphicsmagick_engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pgmagick._pgmagick import get_blob_data

from thumbor.engines import BaseEngine
from thumbor.utils import deprecated

FORMATS = {
'.jpg': 'JPEG',
Expand Down Expand Up @@ -92,9 +93,7 @@ def read(self, extension=None, quality=None):

return img_buffer.data

def convert_to_rgb(self):
return self.get_image_mode(), self.get_image_data()

@deprecated("Use image_data_as_rgb instead.")
def get_image_data(self):
self.image.magick(self.get_image_mode())
blob = Blob()
Expand All @@ -108,11 +107,16 @@ def set_image_data(self, data):
self.image.size(self.image.size())
self.image.read(blob)

@deprecated("Use image_data_as_rgb instead.")
def get_image_mode(self):
if self.image.type() in ALPHA_TYPES:
return "RGBA"
return "RGB"

def image_data_as_rgb(self, update_image=True):
# TODO: Handle other image formats
return self.get_image_mode(), self.get_image_data()

def draw_rectangle(self, x, y, width, height):
draw = Draw()
draw.fill_opacity(0.0)
Expand Down

0 comments on commit 979bcd8

Please sign in to comment.