Skip to content

Commit defa89d

Browse files
committed
Fix duplicate file name extension
If a filename extension and a format are specified with the same string, we create a file with a double file extension. Ie: ```javascript py.image.save_as(figure, 'filename2.png', 'png') ``` This will produce a file named filename2.png.png. When ext and format are both present, the fix will only append format to the filename if the format is different from ext. Ie: ```javascript py.image.save_as(figure, 'filename2.png', 'pdf') ``` This will create filename2.png.pdf.
1 parent 5586407 commit defa89d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

plotly/plotly/plotly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def save_as(cls, figure_or_data, filename, format=None, width=None, height=None)
660660
format = ext[1:]
661661
elif not ext and format:
662662
filename += '.'+format
663-
else:
663+
elif ext[1:].lower() != format.lower():
664664
filename += '.'+format
665665

666666
img = cls.get(figure_or_data, format, width, height)

0 commit comments

Comments
 (0)