File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -298,15 +298,19 @@ def savefig(
298298 "png" : "g" ,
299299 "pdf" : "f" ,
300300 "jpg" : "j" ,
301- "jpeg" : "j" ,
302301 "bmp" : "b" ,
303302 "eps" : "e" ,
304303 "tif" : "t" ,
305304 "kml" : "g" ,
306305 }
307306
308- prefix = Path (fname ).with_suffix ("" ).as_posix ()
309- ext = Path (fname ).suffix [1 :] # suffix without .
307+ fname = Path (fname )
308+ prefix , suffix = fname .with_suffix ("" ).as_posix (), fname .suffix
309+ ext = suffix [1 :]
310+ # alias jpeg to jpg
311+ if ext == "jpeg" :
312+ ext = "jpg"
313+
310314 if ext not in fmts :
311315 if ext == "ps" :
312316 raise GMTInvalidInput (
@@ -329,9 +333,9 @@ def savefig(
329333
330334 self .psconvert (prefix = prefix , fmt = fmt , crop = crop , ** kwargs )
331335
332- # rename .jpg to .jpeg
333- if ext == "jpeg" :
334- Path ( fname ) .with_suffix (".jpg" ).rename (fname )
336+ # Rename if file extension doesn't match the input file suffix
337+ if ext != suffix [ 1 :] :
338+ fname .with_suffix ("." + ext ).rename (fname )
335339
336340 if show :
337341 launch_external_viewer (fname )
You can’t perform that action at this time.
0 commit comments