Skip to content

Commit 87932e0

Browse files
Set image smoothing to "none" by default, per pdfRest
Assisted-by: Codex
1 parent a8a1551 commit 87932e0

2 files changed

Lines changed: 23 additions & 31 deletions

File tree

src/pdfrest/client.py

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ def convert_to_png(
28882888
page_range: str | Sequence[str] | None = None,
28892889
resolution: int = 300,
28902890
color_model: PngColorModel = "rgb",
2891-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
2891+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
28922892
extra_query: Query | None = None,
28932893
extra_headers: AnyMapping | None = None,
28942894
extra_body: Body | None = None,
@@ -2900,13 +2900,12 @@ def convert_to_png(
29002900
"files": files,
29012901
"resolution": resolution,
29022902
"color_model": color_model,
2903+
"smoothing": smoothing,
29032904
}
29042905
if output_prefix is not None:
29052906
payload["output_prefix"] = output_prefix
29062907
if page_range is not None:
29072908
payload["page_range"] = page_range
2908-
if smoothing is not None:
2909-
payload["smoothing"] = smoothing
29102909

29112910
return self._convert_to_graphic(
29122911
endpoint="/png",
@@ -2926,7 +2925,7 @@ def convert_to_bmp(
29262925
page_range: str | Sequence[str] | None = None,
29272926
resolution: int = 300,
29282927
color_model: BmpColorModel = "rgb",
2929-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
2928+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
29302929
extra_query: Query | None = None,
29312930
extra_headers: AnyMapping | None = None,
29322931
extra_body: Body | None = None,
@@ -2938,13 +2937,12 @@ def convert_to_bmp(
29382937
"files": files,
29392938
"resolution": resolution,
29402939
"color_model": color_model,
2940+
"smoothing": smoothing,
29412941
}
29422942
if output_prefix is not None:
29432943
payload["output_prefix"] = output_prefix
29442944
if page_range is not None:
29452945
payload["page_range"] = page_range
2946-
if smoothing is not None:
2947-
payload["smoothing"] = smoothing
29482946

29492947
return self._convert_to_graphic(
29502948
endpoint="/bmp",
@@ -2964,7 +2962,7 @@ def convert_to_gif(
29642962
page_range: str | Sequence[str] | None = None,
29652963
resolution: int = 300,
29662964
color_model: GifColorModel = "rgb",
2967-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
2965+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
29682966
extra_query: Query | None = None,
29692967
extra_headers: AnyMapping | None = None,
29702968
extra_body: Body | None = None,
@@ -2976,13 +2974,12 @@ def convert_to_gif(
29762974
"files": files,
29772975
"resolution": resolution,
29782976
"color_model": color_model,
2977+
"smoothing": smoothing,
29792978
}
29802979
if output_prefix is not None:
29812980
payload["output_prefix"] = output_prefix
29822981
if page_range is not None:
29832982
payload["page_range"] = page_range
2984-
if smoothing is not None:
2985-
payload["smoothing"] = smoothing
29862983

29872984
return self._convert_to_graphic(
29882985
endpoint="/gif",
@@ -3002,7 +2999,7 @@ def convert_to_jpeg(
30022999
page_range: str | Sequence[str] | None = None,
30033000
resolution: int = 300,
30043001
color_model: JpegColorModel = "rgb",
3005-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
3002+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
30063003
jpeg_quality: int = 75,
30073004
extra_query: Query | None = None,
30083005
extra_headers: AnyMapping | None = None,
@@ -3015,14 +3012,13 @@ def convert_to_jpeg(
30153012
"files": files,
30163013
"resolution": resolution,
30173014
"color_model": color_model,
3015+
"smoothing": smoothing,
30183016
"jpeg_quality": jpeg_quality,
30193017
}
30203018
if output_prefix is not None:
30213019
payload["output_prefix"] = output_prefix
30223020
if page_range is not None:
30233021
payload["page_range"] = page_range
3024-
if smoothing is not None:
3025-
payload["smoothing"] = smoothing
30263022

30273023
return self._convert_to_graphic(
30283024
endpoint="/jpg",
@@ -3042,7 +3038,7 @@ def convert_to_tiff(
30423038
page_range: str | Sequence[str] | None = None,
30433039
resolution: int = 300,
30443040
color_model: TiffColorModel = "rgb",
3045-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
3041+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
30463042
extra_query: Query | None = None,
30473043
extra_headers: AnyMapping | None = None,
30483044
extra_body: Body | None = None,
@@ -3054,13 +3050,12 @@ def convert_to_tiff(
30543050
"files": files,
30553051
"resolution": resolution,
30563052
"color_model": color_model,
3053+
"smoothing": smoothing,
30573054
}
30583055
if output_prefix is not None:
30593056
payload["output_prefix"] = output_prefix
30603057
if page_range is not None:
30613058
payload["page_range"] = page_range
3062-
if smoothing is not None:
3063-
payload["smoothing"] = smoothing
30643059

30653060
return self._convert_to_graphic(
30663061
endpoint="/tif",
@@ -3931,7 +3926,7 @@ async def convert_to_png(
39313926
page_range: str | Sequence[str] | None = None,
39323927
resolution: int = 300,
39333928
color_model: PngColorModel = "rgb",
3934-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
3929+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
39353930
extra_query: Query | None = None,
39363931
extra_headers: AnyMapping | None = None,
39373932
extra_body: Body | None = None,
@@ -3943,13 +3938,12 @@ async def convert_to_png(
39433938
"files": files,
39443939
"resolution": resolution,
39453940
"color_model": color_model,
3941+
"smoothing": smoothing,
39463942
}
39473943
if output_prefix is not None:
39483944
payload["output_prefix"] = output_prefix
39493945
if page_range is not None:
39503946
payload["page_range"] = page_range
3951-
if smoothing is not None:
3952-
payload["smoothing"] = smoothing
39533947

39543948
return await self._convert_to_graphic(
39553949
endpoint="/png",
@@ -3969,7 +3963,7 @@ async def convert_to_bmp(
39693963
page_range: str | Sequence[str] | None = None,
39703964
resolution: int = 300,
39713965
color_model: BmpColorModel = "rgb",
3972-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
3966+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
39733967
extra_query: Query | None = None,
39743968
extra_headers: AnyMapping | None = None,
39753969
extra_body: Body | None = None,
@@ -3981,13 +3975,12 @@ async def convert_to_bmp(
39813975
"files": files,
39823976
"resolution": resolution,
39833977
"color_model": color_model,
3978+
"smoothing": smoothing,
39843979
}
39853980
if output_prefix is not None:
39863981
payload["output_prefix"] = output_prefix
39873982
if page_range is not None:
39883983
payload["page_range"] = page_range
3989-
if smoothing is not None:
3990-
payload["smoothing"] = smoothing
39913984

39923985
return await self._convert_to_graphic(
39933986
endpoint="/bmp",
@@ -4007,7 +4000,7 @@ async def convert_to_gif(
40074000
page_range: str | Sequence[str] | None = None,
40084001
resolution: int = 300,
40094002
color_model: GifColorModel = "rgb",
4010-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
4003+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
40114004
extra_query: Query | None = None,
40124005
extra_headers: AnyMapping | None = None,
40134006
extra_body: Body | None = None,
@@ -4019,13 +4012,12 @@ async def convert_to_gif(
40194012
"files": files,
40204013
"resolution": resolution,
40214014
"color_model": color_model,
4015+
"smoothing": smoothing,
40224016
}
40234017
if output_prefix is not None:
40244018
payload["output_prefix"] = output_prefix
40254019
if page_range is not None:
40264020
payload["page_range"] = page_range
4027-
if smoothing is not None:
4028-
payload["smoothing"] = smoothing
40294021

40304022
return await self._convert_to_graphic(
40314023
endpoint="/gif",
@@ -4045,7 +4037,7 @@ async def convert_to_jpeg(
40454037
page_range: str | Sequence[str] | None = None,
40464038
resolution: int = 300,
40474039
color_model: JpegColorModel = "rgb",
4048-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
4040+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
40494041
jpeg_quality: int = 75,
40504042
extra_query: Query | None = None,
40514043
extra_headers: AnyMapping | None = None,
@@ -4058,14 +4050,13 @@ async def convert_to_jpeg(
40584050
"files": files,
40594051
"resolution": resolution,
40604052
"color_model": color_model,
4053+
"smoothing": smoothing,
40614054
"jpeg_quality": jpeg_quality,
40624055
}
40634056
if output_prefix is not None:
40644057
payload["output_prefix"] = output_prefix
40654058
if page_range is not None:
40664059
payload["page_range"] = page_range
4067-
if smoothing is not None:
4068-
payload["smoothing"] = smoothing
40694060

40704061
return await self._convert_to_graphic(
40714062
endpoint="/jpg",
@@ -4085,7 +4076,7 @@ async def convert_to_tiff(
40854076
page_range: str | Sequence[str] | None = None,
40864077
resolution: int = 300,
40874078
color_model: TiffColorModel = "rgb",
4088-
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] | None = None,
4079+
smoothing: GraphicSmoothing | Sequence[GraphicSmoothing] = "none",
40894080
extra_query: Query | None = None,
40904081
extra_headers: AnyMapping | None = None,
40914082
extra_body: Body | None = None,
@@ -4097,13 +4088,12 @@ async def convert_to_tiff(
40974088
"files": files,
40984089
"resolution": resolution,
40994090
"color_model": color_model,
4091+
"smoothing": smoothing,
41004092
}
41014093
if output_prefix is not None:
41024094
payload["output_prefix"] = output_prefix
41034095
if page_range is not None:
41044096
payload["page_range"] = page_range
4105-
if smoothing is not None:
4106-
payload["smoothing"] = smoothing
41074097

41084098
return await self._convert_to_graphic(
41094099
endpoint="/tif",

tests/graphics_test_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ def assert_conversion_payload(
4949
for key, value in expected.items():
5050
assert payload[key] == value
5151
extra_keys = set(payload) - set(expected)
52-
permitted = {"color_model", "resolution"}
52+
permitted = {"color_model", "resolution", "smoothing"}
5353
if allowed_extras is not None:
5454
permitted.update(allowed_extras)
5555
assert extra_keys <= permitted
5656
if "resolution" not in expected and "resolution" in payload:
5757
assert payload["resolution"] == 300
5858
if "color_model" not in expected and "color_model" in payload:
5959
assert payload["color_model"] == "rgb"
60+
if "smoothing" not in expected and "smoothing" in payload:
61+
assert payload["smoothing"] == "none"

0 commit comments

Comments
 (0)