Skip to content

Emf support for save as #1306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
describes a plotly figure.
Same argument used in `py.plot`, `py.iplot`,
see https://plot.ly/python for examples
- format: 'png', 'svg', 'jpeg', 'pdf'
- format: 'png', 'svg', 'jpeg', 'pdf', 'emf'
- width: output width
- height: output height
- scale: Increase the resolution of the image by `scale`
Expand All @@ -730,7 +730,7 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
# TODO: format is a built-in name... we shouldn't really use it
figure = tools.return_figure_from_figure_or_data(figure_or_data, True)

if format not in ['png', 'svg', 'jpeg', 'pdf']:
if format not in ['png', 'svg', 'jpeg', 'pdf', 'emf']:
raise exceptions.PlotlyError(
"Invalid format. This version of your Plotly-Python "
"package currently only supports png, svg, jpeg, and pdf. "
Expand Down Expand Up @@ -760,7 +760,8 @@ def get(figure_or_data, format='png', width=None, height=None, scale=None):
if ('content-type' in headers and
headers['content-type'] in ['image/png', 'image/jpeg',
'application/pdf',
'image/svg+xml']):
'image/svg+xml',
'image/emf']):
return response.content
elif ('content-type' in headers and
'json' in headers['content-type']):
Expand Down Expand Up @@ -809,7 +810,7 @@ def save_as(cls, figure_or_data, filename, format=None, width=None,
"""Save a image of the plot described by `figure_or_data` locally as
`filename`.

Valid image formats are 'png', 'svg', 'jpeg', and 'pdf'.
Valid image formats are 'png', 'svg', 'jpeg', 'pdf' and 'emf'.
The format is taken as the extension of the filename or as the
supplied format.

Expand All @@ -819,7 +820,7 @@ def save_as(cls, figure_or_data, filename, format=None, width=None,
Same argument used in `py.plot`, `py.iplot`,
see https://plot.ly/python for examples
- filename: The filepath to save the image to
- format: 'png', 'svg', 'jpeg', 'pdf'
- format: 'png', 'svg', 'jpeg', 'pdf', 'emf'
- width: output width
- height: output height
- scale: Increase the resolution of the image by `scale` amount
Expand Down
8 changes: 1 addition & 7 deletions plotly/tests/test_plot_ly/test_image/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _test(self):
return _test

kwargs = {
'format': ['png', 'jpeg', 'pdf', 'svg'],
'format': ['png', 'jpeg', 'pdf', 'svg', 'emf'],
'width': [None, 300],
'height': [None, 300],
'scale': [None, 5]
Expand All @@ -70,12 +70,6 @@ def _test(self):
for test_generator in [_generate_image_get_returns_valid_image_test,
_generate_image_save_as_saves_valid_image]:

if args[0] in ['jpeg', 'pdf', 'svg'] and args[3] is not None:
# Shouldn't need to skip these tests, the server should
# be responding with a 400 level error since scale isn't supported,
# but it doesn't yet, so just skip them
continue

_test = test_generator(*args)
arg_string = ', '.join([str(a) for a in args])
test_name = test_generator.__name__.replace('_generate', 'test')
Expand Down