File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -298,15 +298,20 @@ 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+
309+ prefix , suffix = fname .with_suffix ("" ).as_posix (), fname .suffix
310+ ext = suffix [1 :]
311+ # alias jpeg to jpg
312+ if ext == "jpeg" :
313+ ext = "jpg"
314+
310315 if ext not in fmts :
311316 if ext == "ps" :
312317 raise GMTInvalidInput (
@@ -329,9 +334,9 @@ def savefig(
329334
330335 self .psconvert (prefix = prefix , fmt = fmt , crop = crop , ** kwargs )
331336
332- # rename .jpg to .jpeg
333- if ext == "jpeg" :
334- Path ( fname ) .with_suffix (".jpg" ).rename (fname )
337+ # Rename if file extension doesn't match the input file suffix
338+ if ext != suffix [ 1 :] :
339+ fname .with_suffix ("." + ext ).rename (fname )
335340
336341 if show :
337342 launch_external_viewer (fname )
You can’t perform that action at this time.
0 commit comments