Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita54d4e1

Browse files
committed
Remove JPEG-specific parameters and rcParams.
1 parente6fd901 commita54d4e1

File tree

7 files changed

+14
-76
lines changed

7 files changed

+14
-76
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
jpeg-related keywords and rcParams
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Support has been removed for the *quality*, *optimize*, and *progressive*
5+
parameters of `.Figure.savefig` (which only affected jpeg output), as well as
6+
:rc:`savefig.jpeg_quality`. This support has also been removed from the
7+
corresponding ``print_jpg`` methods.
8+
9+
JPEG output options can be set by directly passing the relevant parameters in
10+
*pil_kwargs*.

‎lib/matplotlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ def gen_candidates():
552552
'animation.avconv_path': ('3.3',),
553553
'animation.avconv_args': ('3.3',),
554554
'animation.html_args': ('3.3',),
555-
'savefig.jpeg_quality': ('3.3',),
556555
}
557556

558557

‎lib/matplotlib/backends/backend_agg.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -522,14 +522,7 @@ def print_to_buffer(self):
522522
# print_figure(), and the latter ensures that `self.figure.dpi` already
523523
# matches the dpi kwarg (if any).
524524

525-
@_check_savefig_extra_args(
526-
extra_kwargs=["quality","optimize","progressive"])
527-
@_api.delete_parameter("3.3","quality",
528-
alternative="pil_kwargs={'quality': ...}")
529-
@_api.delete_parameter("3.3","optimize",
530-
alternative="pil_kwargs={'optimize': ...}")
531-
@_api.delete_parameter("3.3","progressive",
532-
alternative="pil_kwargs={'progressive': ...}")
525+
@_check_savefig_extra_args()
533526
@_api.delete_parameter("3.5","args")
534527
defprint_jpg(self,filename_or_obj,*args,pil_kwargs=None,**kwargs):
535528
"""
@@ -542,23 +535,9 @@ def print_jpg(self, filename_or_obj, *args, pil_kwargs=None, **kwargs):
542535
543536
Other Parameters
544537
----------------
545-
quality : int, default: :rc:`savefig.jpeg_quality`
546-
The image quality, on a scale from 1 (worst) to 95 (best).
547-
Values above 95 should be avoided; 100 disables portions of
548-
the JPEG compression algorithm, and results in large files
549-
with hardly any gain in image quality. This parameter is
550-
deprecated.
551-
optimize : bool, default: False
552-
Whether the encoder should make an extra pass over the image
553-
in order to select optimal encoder settings. This parameter is
554-
deprecated.
555-
progressive : bool, default: False
556-
Whether the image should be stored as a progressive JPEG file.
557-
This parameter is deprecated.
558538
pil_kwargs : dict, optional
559539
Additional keyword arguments that are passed to
560-
`PIL.Image.Image.save` when saving the figure. These take
561-
precedence over *quality*, *optimize* and *progressive*.
540+
`PIL.Image.Image.save` when saving the figure.
562541
"""
563542
# Remove transparency by alpha-blending on an assumed white background.
564543
r,g,b,a=mcolors.to_rgba(self.figure.get_facecolor())
@@ -569,19 +548,6 @@ def print_jpg(self, filename_or_obj, *args, pil_kwargs=None, **kwargs):
569548
self.figure.set_facecolor((r,g,b,a))
570549
ifpil_kwargsisNone:
571550
pil_kwargs= {}
572-
forkin ["quality","optimize","progressive"]:
573-
ifkinkwargs:
574-
pil_kwargs.setdefault(k,kwargs.pop(k))
575-
if"quality"notinpil_kwargs:
576-
quality=pil_kwargs["quality"]= \
577-
dict.__getitem__(mpl.rcParams,"savefig.jpeg_quality")
578-
ifqualitynotin [0,75,95]:# default qualities.
579-
_api.warn_deprecated(
580-
"3.3",name="savefig.jpeg_quality",obj_type="rcParam",
581-
addendum="Set the quality using "
582-
"`pil_kwargs={'quality': ...}`; the future default "
583-
"quality will be 75, matching the default of Pillow and "
584-
"libjpeg.")
585551
pil_kwargs.setdefault("dpi", (self.figure.dpi,self.figure.dpi))
586552
# Drop alpha channel now.
587553
return (Image.fromarray(np.asarray(self.buffer_rgba())[..., :3])

‎lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def draw(self, drawDC=None):
831831
self.gui_repaint(drawDC=drawDC)
832832

833833
@_check_savefig_extra_args
834-
def_print_image(self,filetype,filename,*,quality=None):
834+
def_print_image(self,filetype,filename):
835835
origBitmap=self.bitmap
836836

837837
self.bitmap=wx.Bitmap(math.ceil(self.figure.bbox.width),
@@ -843,16 +843,6 @@ def _print_image(self, filetype, filename, *, quality=None):
843843

844844
# image is the object that we call SaveFile on.
845845
image=self.bitmap
846-
# set the JPEG quality appropriately. Unfortunately, it is only
847-
# possible to set the quality on a wx.Image object. So if we
848-
# are saving a JPEG, convert the wx.Bitmap to a wx.Image,
849-
# and set the quality.
850-
iffiletype==wx.BITMAP_TYPE_JPEG:
851-
ifqualityisNone:
852-
quality=dict.__getitem__(mpl.rcParams,
853-
'savefig.jpeg_quality')
854-
image=self.bitmap.ConvertToImage()
855-
image.SetOption(wx.IMAGE_OPTION_QUALITY,str(quality))
856846

857847
# Now that we have rendered into the bitmap, save it to the appropriate
858848
# file type and clean up.

‎lib/matplotlib/figure.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2840,31 +2840,6 @@ def savefig(self, fname, *, transparent=None, **kwargs):
28402840
The resolution in dots per inch. If 'figure', use the figure's
28412841
dpi value.
28422842
2843-
quality : int, default: :rc:`savefig.jpeg_quality`
2844-
Applicable only if *format* is 'jpg' or 'jpeg', ignored otherwise.
2845-
2846-
The image quality, on a scale from 1 (worst) to 95 (best).
2847-
Values above 95 should be avoided; 100 disables portions of
2848-
the JPEG compression algorithm, and results in large files
2849-
with hardly any gain in image quality.
2850-
2851-
This parameter is deprecated.
2852-
2853-
optimize : bool, default: False
2854-
Applicable only if *format* is 'jpg' or 'jpeg', ignored otherwise.
2855-
2856-
Whether the encoder should make an extra pass over the image
2857-
in order to select optimal encoder settings.
2858-
2859-
This parameter is deprecated.
2860-
2861-
progressive : bool, default: False
2862-
Applicable only if *format* is 'jpg' or 'jpeg', ignored otherwise.
2863-
2864-
Whether the image should be stored as a progressive JPEG file.
2865-
2866-
This parameter is deprecated.
2867-
28682843
facecolor : color or 'auto', default: :rc:`savefig.facecolor`
28692844
The facecolor of the figure. If 'auto', use the current figure
28702845
facecolor.

‎lib/matplotlib/rcsetup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,6 @@ def _convert_validator_spec(key, conv):
13181318
'savefig.facecolor':validate_color_or_auto,
13191319
'savefig.edgecolor':validate_color_or_auto,
13201320
'savefig.orientation': ['landscape','portrait'],
1321-
'savefig.jpeg_quality':validate_int,
13221321
"savefig.format":validate_string,
13231322
"savefig.bbox":validate_bbox,# "tight", or "standard" (= None)
13241323
"savefig.pad_inches":validate_float,
@@ -1420,7 +1419,6 @@ def _convert_validator_spec(key, conv):
14201419
"animation.avconv_path":"avconv",
14211420
"animation.avconv_args": [],
14221421
"animation.html_args": [],
1423-
"savefig.jpeg_quality":95,
14241422
}
14251423
_validators= {k:_convert_validator_spec(k,conv)
14261424
fork,convin_validators.items()}

‎lib/matplotlib/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def test_jpeg_alpha():
636636
# If this fails, there will be only one color (all black). If this
637637
# is working, we should have all 256 shades of grey represented.
638638
num_colors=len(image.getcolors(256))
639-
assert175<=num_colors<=185
639+
assert175<=num_colors<=210
640640
# The fully transparent part should be red.
641641
corner_pixel=image.getpixel((0,0))
642642
assertcorner_pixel== (254,0,0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp