1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
|
%global _empty_manifest_terminate_build 0
Name: python-imgix
Version: 4.0.0
Release: 1
Summary: Python client library for imgix.
License: BSD-2-Clause
URL: https://github.com/imgix/imgix-python
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/dd/e4/6f85b8e39dd73dcd497e9d525f157f1210479db69aa161f9efa1765491fd/imgix-4.0.0.tar.gz
BuildArch: noarch
Requires: python3-tox
Requires: python3-pytest
Requires: python3-pytest-cov
Requires: python3-flake8
%description
<!-- /ix-docs-ignore -->
- [Installation](#installation)
- [Usage](#usage)
- [Signed URLs](#signed-urls)
- [Disabled Path Encoding](#disabled-path-encoding)
- [Srcset Generation](#srcset-generation)
* [Fixed-Width Images](#fixed-width-images)
+ [Variable Quality](#variable-quality)
* [Fluid-Width Images](#fluid-width-images)
+ [Custom Widths](#custom-widths)
+ [Width Ranges](#width-ranges)
+ [Width Tolerance](#width-tolerance)
+ [Explore Target Widths](#explore-target-widths)
* [Usage with UTF-8](#usage-with-utf-8)
- [The `ixlib` Parameter](#the-ixlib-parameter)
- [Testing](#testing)
- [License](#license)
## Installation
``` bash
pip install imgix
```
## Usage
To begin creating imgix URLs, import the imgix library and create a URL builder. The URL builder can be reused to create URLs for any images on the domains it is provided.
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net")
>>> ub.create_url("bridge.png", {'w': 100, 'h': 100})
'https://demo.imgix.net/bridge.png?h=100&w=100'
```
_HTTPS_ support is enabled by default. _HTTP_ can be toggled on by setting `use_https` to `False`:
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net", use_https=False)
>>> ub.create_url("/bridge.png", {'w': 100, 'h': 100})
'http://demo.imgix.net/bridge.png?h=100&w=100'
```
## Signed URLs
To produce a signed URL, you must enable secure URLs on your source and then provide your signature key to the URL builder.
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net", sign_key="test1234")
>>> ub.create_url("/bridge.png", {'w': 100, 'h': 100})
'https://demo.imgix.net/bridge.png?h=100&w=100&s=bb8f3a2ab832e35997456823272103a4'
```
## Disabled Path Encoding
Path encoding is enabled by default. It can be toggled off by setting `disable_path_encoding` to `True` in the optional `options` paramater in `create_url()` and `create_srcset()` functions:
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("sdk-test.imgix.net")
>>> ub.create_url(" <>[]{}|^%.jpg", params={'w': 100, 'h': 100}, options={'disable_path_encoding': True})
'https://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100'
```
Normally this would output a source URL like `https://demo.imgix.net/%20%3C%3E%5B%5D%7B%7D%7C%5E%25.jpg?h=100&2=100`, but since path encoding is disabled, it will output a source URL like `https://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100`.
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("sdk-test.imgix.net")
>>> ub.create_srcset("image<>[]{} 123.png", widths=[100], options={'disable_path_encoding': True})
'https://sdk-test.imgix.net/image<>[]{} 123.png?w=100 100w'
```
Normally this would output a source URL like `https://sdk-test.imgix.net/image%3C%3E%5B%5D%7B%7D%20123.png?&w=100 100w`, but since path encoding is disabled, it will output a source URL like `https://sdk-test.imgix.net//image<>[]{} 123.png?w=100 100w`.
## Srcset Generation
The imgix-python package allows for generation of custom srcset attributes, which can be invoked through the `create_srcset` method. By default, the generated srcset will allow for responsive size switching by building a list of image-width mappings.
``` python
import os
from imgix import UrlBuilder
# Keep Your Secrets Safe!
SECRET = os.getenv("IX_SIGN_KEY")
ub = UrlBuilder("demos.imgix.net", sign_key=SECRET)
srcset = ub.create_srcset("image.png")
```
The above will produce the following srcset attribute value which can then be served to the client:
``` html
https://demos.imgix.net/image.png?w=100&s=e415797545a77a9d2842dedcfe539c9a 100w,
https://demos.imgix.net/image.png?w=116&s=b2da46f5c23ef13d5da30f0a4545f33f 116w,
https://demos.imgix.net/image.png?w=135&s=b61422dead929f893c04b8ff839bb088 135w,
https://demos.imgix.net/image.png?w=7401&s=ad671301ed4663c3ce6e84cb646acb96 7401w,
https://demos.imgix.net/image.png?w=8192&s=a0fed46e2bbcc70ded13dc629aee5398 8192w
```
### Fixed-Width Images
In cases where enough information is provided about an image's dimensions, `create_srcset` will instead build a srcset that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are `w`, `h`, and `ar`.
By invoking `create_srcset` with either a width **or** the height and aspect ratio (along with `fit=crop`, typically) provided, a different srcset will be generated for a fixed-width image instead.
``` python
from imgix import UrlBuilder
>>> ub = UrlBuilder("demos.imgix.net", sign_key="my-token")
>>> srcset = ub.create_srcset("image.png", {'h':800, 'ar':'3:2', 'fit':'crop'})
```
Will produce the following attribute value:
``` html
https://demos.imgix.net/image.png?ar=3%3A2&dpr=1&fit=crop&h=800&s=6cf5c443d1eb98bc3d96ea569fcef088 1x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=2&fit=crop&h=800&s=d60a61a5f34545922bd8dff4e53a0555 2x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=3&fit=crop&h=800&s=590f96aa426f8589eb7e449ebbeb66e7 3x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=4&fit=crop&h=800&s=c89c2fd3148957647e86cfc32ba20517 4x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=5&fit=crop&h=800&s=3d73af69d78d49eef0f81b4b5d718a2c 5x
```
By default, this library generates a `srcset` with pixel density values of `1` through `5`.
These target ratios can be controlled by using the `devicePixelRatios` parameters.
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset(
"image.jpg",
{ "w": 100 },
{
"device_pixel_ratios": [ 1, 2, 3 ]
}
)
```
Will produce the following attribute value:
```html
https://demo.imgix.net/image.jpg?dpr=1&ixlib=python-3.2.1&q=75&w=100 1x,
https://demo.imgix.net/image.jpg?dpr=2&ixlib=python-3.2.1&q=50&w=100 2x,
https://demo.imgix.net/image.jpg?dpr=3&ixlib=python-3.2.1&q=35&w=100 3x'
```
For more information to better understand srcset, we highly recommend
[Eric Portis' "Srcset and sizes" article](https://ericportis.com/posts/2014/srcset-sizes/) which goes into depth about the subject.
#### Variable Quality
This library will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a [fixed-width image](#fixed-width-images) srcset. This technique is commonly used to compensate for the increased file size of high-DPR images.
Since high-DPR images are displayed at a higher pixel density on devices, image quality can be lowered to reduce overall file size––without sacrificing perceived visual quality. For more information and examples of this technique in action, see [this blog post](https://blog.imgix.com/2016/03/30/dpr-quality).
This behavior will respect any overriding `q` value passed in as a parameter. Additionally, it can be disabled altogether by passing `disable_variable_quality = true` to `create_srcset`.
This behavior specifically occurs when a [fixed-width image](#fixed-width-images) is rendered, for example:
```python
# Note that `params={"w": 100}` allows `create_srcset` to _infer_ the creation
# of a DPR based srcset attribute for fixed-width images.
ub = imgix.UrlBuilder('demo.imgix.net')
# Set `disable_variable_quality` to True to disable variable quality.
srcset = ub.create_srcset('image.jpg', params={"w": 100}, disable_variable_quality=False)
```
The above will generate a srcset with the following `q` to `dpr` query `params`:
```html
https://demo.imgix.net/image.jpg?w=100&dpr=1&q=75 1x,
https://demo.imgix.net/image.jpg?w=100&dpr=2&q=50 2x,
https://demo.imgix.net/image.jpg?w=100&dpr=3&q=35 3x,
https://demo.imgix.net/image.jpg?w=100&dpr=4&q=23 4x,
https://demo.imgix.net/image.jpg?w=100&dpr=5&q=20 5x
```
By default, this library will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a [fixed-width image](#fixed-width-images) srcset.
To customize variable qualities, you can pass a `variable_qualities` dictionary in the `options` while creating srcset as below:
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset("image.jpg", {"w": 100}, {"variable_qualities": {1: 45, 2: 30, 3: 20, 4: 15, 5: 10}})
```
The above script will produce the following output:
```bash
https://demo.imgix.net/image.jpg?dpr=1&q=45&w=100 1x
https://demo.imgix.net/image.jpg?dpr=2&q=30&w=100 2x
https://demo.imgix.net/image.jpg?dpr=3&q=20&w=100 3x
https://demo.imgix.net/image.jpg?dpr=4&&q=15&w=100 4x
https://demo.imgix.net/image.jpg?dpr=5&q=10&w=100 5x
```
You can also pass `variable_qualities` along with the `device_pixel_ratios` option as below:
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset(
"image.jpg",
{ "w": 100 },
{
"device_pixel_ratios": [ 1, 2, 3 ],
"variable_qualities": { 1: 45, 2: 30, 3: 20 }
}
)
```
The above script will produce the following output:
```html
https://testing.imgix.net/image.jpg?dpr=1&q=45&w=100 1x,
https://testing.imgix.net/image.jpg?dpr=2&q=30&w=100 2x,
https://testing.imgix.net/image.jpg?dpr=3&q=20&w=100 3x
```
### Fluid-Width Images
#### Custom Widths
In situations where specific widths are desired when generating `srcset` pairs, a user can specify them by passing an array of positive integers as `widths`:
``` python
>>> from imgix import UrlBuilder
>>> builder = UrlBuilder('demo.imgix.net')
>>> builder.create_srcset('image.jpg', widths=[144, 240, 320, 446, 640])
'https://demo.imgix.net/image.jpg?w=144 144w,\nhttps://demo.imgix.net/image.jpg?w=240 240w,\nhttps://demo.imgix.net/image.jpg?w=320 320w,\nhttps://demo.imgix.net/image.jpg?w=446 446w,\nhttps://demo.imgix.net/image.jpg?w=640 640w'
```
```html
https://demo.imgix.net/image.jpg?w=144 144w,
https://demo.imgix.net/image.jpg?w=240 240w,
https://demo.imgix.net/image.jpg?w=320 320w,
https://demo.imgix.net/image.jpg?w=446 446w,
https://demo.imgix.net/image.jpg?w=640 640w
```
**Note**: in situations where a `srcset` is being rendered as a [fixed-width](#fixed-width-images) srcset, any custom `widths` passed in will be ignored.
Additionally, if both `widths` and a width `tol`erance are passed to the `create_srcset` method, the custom widths list will take precedence.
#### Width Ranges
In certain circumstances, you may want to limit the minimum or maximum value of the non-fixed `srcset` generated by the `create_srcset` method. To do this, you can specify the widths at which a srcset should `start` and `stop`:
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder('demo.imgix.net')
>>> ub.create_srcset('image.jpg', start=500, stop=2000)
'https://demo.imgix.net/image.jpg?w=500 500w,\nhttps://demo.imgix.net/image.jpg?w=580 580w,\nhttps://demo.imgix.net/image.jpg?w=673 673w,\nhttps://demo.imgix.net/image.jpg?w=780 780w,\nhttps://demo.imgix.net/image.jpg?w=905 905w,\nhttps://demo.imgix.net/image.jpg?w=1050 1050w,\nhttps://demo.imgix.net/image.jpg?w=1218 1218w,\nhttps://demo.imgix.net/image.jpg?w=1413 1413w,\nhttps://demo.imgix.net/image.jpg?w=1639 1639w,\nhttps://demo.imgix.net/image.jpg?w=1901 1901w,\nhttps://demo.imgix.net/image.jpg?w=2000 2000w'
```
Formatted version of the above srcset attribute:
``` html
https://demo.imgix.net/image.jpg?w=500 500w,
https://demo.imgix.net/image.jpg?w=580 580w,
https://demo.imgix.net/image.jpg?w=673 673w,
https://demo.imgix.net/image.jpg?w=780 780w,
https://demo.imgix.net/image.jpg?w=905 905w,
https://demo.imgix.net/image.jpg?w=1050 1050w,
https://demo.imgix.net/image.jpg?w=1218 1218w,
https://demo.imgix.net/image.jpg?w=1413 1413w,
https://demo.imgix.net/image.jpg?w=1639 1639w,
https://demo.imgix.net/image.jpg?w=1901 1901w,
https://demo.imgix.net/image.jpg?w=2000 2000w'
```
#### Width Tolerance
The `srcset` width `tol`erance dictates the maximum `tol`erated difference between an image's downloaded size and its rendered size.
For example, setting this value to `0.10` means that an image will not render more than 10% larger or smaller than its native size. In practice, the image URLs generated for a width-based srcset attribute will grow by twice this rate.
A lower tolerance means images will render closer to their native size (thereby increasing perceived image quality), but a large srcset list will be generated and consequently users may experience lower rates of cache-hit for pre-rendered images on your site.
By default, srcset width `tol`erance is set to 0.08 (8 percent), which we consider to be the ideal rate for maximizing cache hits without sacrificing visual quality. Users can specify their own width tolerance by providing a positive scalar value as width `tol`erance:
```python
>>> import imgix
>>> ub = imgix.UrlBuilder('demo.imgix.net')
>>> srcset = ub.create_srcset('image.jpg', start=100, stop=384, tol=0.20)
```
In this case, the `width_tolerance` is set to 20 percent, which will be reflected in the difference between subsequent widths in a srcset pair:
```html
https://demo.imgix.net/image.jpg?w=100 100w,
https://demo.imgix.net/image.jpg?w=140 140w,
https://demo.imgix.net/image.jpg?w=196 196w,
https://demo.imgix.net/image.jpg?w=274 274w,
https://demo.imgix.net/image.jpg?w=384 384w
```
#### Explore Target Widths
The `target_widths` function is used internally to generate lists of target widths to be used in calls to `create_srcset`.
It is a way to generate, play with, and explore different target widths separately from srcset attributes. One way of generating a srcset attribute is:
```python
srcset = ub.create_srcset('image.jpg', start=300, stop=3000, tol=0.13)
```
The above is convenient if `start`, `stop`, and `tol`erance are known in advance. Another approach is to use `target_widths` to determine which combination of values for `start`, `stop`, and `tol`erance work best.
```python
>>> from imgix import UrlBuilder, target_widths
>>> # Create
>>> widths = target_widths(300, 3000, 0.13)
>>> widths
[300, 378, 476, 600, 756, 953, 1200, 1513, 1906, 2401, 3000]
>>> # Explore
>>> sm, md, lg = widths[:3], widths[3:7], widths[7:]
>>> widths = [w for w in widths[1::2]]
>>> widths
[378, 600, 953, 1513, 2401]
>>> # Serve
>>> ub = UrlBuilder('demo.imgix.net')
>>> srcset = ub.create_srcset('image.png', widths=widths)
>>> srcset
'https://demo.imgix.net/image.png?w=378 378w,\nhttps://demo.imgix.net/image.png?w=600 600w,\nhttps://demo.imgix.net/image.png?w=953 953w,\nhttps://demo.imgix.net/image.png?w=1513 1513w,\nhttps://demo.imgix.net/image.png?w=2401 2401w'
```
### Usage with UTF-8
For usage with non-ASCII characters, please be sure that your project's source files specify UTF-8 encoding:
``` python
# -*- coding: utf-8 -*-
```
If you don't add this encoding, and you have an image with the name 'tiburón.jpeg', for example, you will get the following error trying to run your script:
``` python
SyntaxError: Non-ASCII character '***' in file test.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
```
## The `ixlib` Parameter
For security and diagnostic purposes, we sign all requests with the language and version of library used to generate the URL.
This can be disabled by setting `include_library_param` to `False` like so:
``` python
UrlBuilder('demo.imgix.net', include_library_param=False)
```
## Testing
Run the following to execute the project's tests and code linter:
``` bash
tox
```
If you have cloned this repo or downloaded it locally, you can also run `python -m doctest -v README.md` to test the examples in this readme.
## License
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-python?ref=badge_large)
# Changelog
## [4.0.0](https://github.com/imgix/imgix-python/compare/3.2.1...4.0.0) (2022-12-08)
### Breaking Changes
- feat: drop python 2 support ([#88](https://github.com/imgix/imgix-python/pull/88))
- fix: fixed-height produces dpr-based srcset ([#88](https://github.com/imgix/imgix-python/pull/88))
- feat: encode file path components ([#88](https://github.com/imgix/imgix-python/pull/88))
### Features
- feat: add path encoding to be disabled optionally ([#98](https://github.com/imgix/imgix-python/pull/98))
- feat: customize variable qualities in options ([#102](https://github.com/imgix/imgix-python/pull/102))
- feat: customize target device pixel ratios ([#103](https://github.com/imgix/imgix-python/pull/103))
## [3.2.1](https://github.com/imgix/imgix-python/compare/3.2.0...3.2.1) (2020-06-10)
- refactor: relax validation for min/max width values ([#80](https://github.com/imgix/imgix-python/pull/80))
## [3.2.0](https://github.com/imgix/imgix-python/compare/3.1.2...3.2.0) (2020-06-05)
- feat: create custom srcset ([#63](https://github.com/imgix/imgix-python/pull/63))
- feat: introduce variable image output quality ([#65](https://github.com/imgix/imgix-python/pull/65))
- fix: remove ensure even ([#72](https://github.com/imgix/imgix-python/pull/72))
- feat: throw exceptions from validators ([#77](https://github.com/imgix/imgix-python/pull/77))
- fix: convert tol to float ([#75](https://github.com/imgix/imgix-python/pull/75))
## [3.1.2](https://github.com/imgix/imgix-python/compare/3.1.1...3.1.2) (2020-03-11)
- Fix Python 2/3 compatibility issues
([\#57](https://github.com/imgix/imgix-python/pull/57))
## [3.1.1](https://github.com/imgix/imgix-python/compare/3.1.0...3.1.1) (2019-08-22)
- fix: include dpr parameter when generating fixed-width srcset
([\#50](https://github.com/imgix/imgix-python/pull/50))
## [3.1.0](https://github.com/imgix/imgix-python/compare/3.0.0...3.1.0) (2019-08-22)
- feat: add srcset generation
([\#48](https://github.com/imgix/imgix-python/pull/48))
- build(tox): improve code coverage reporting; parallelize testing
([\#49](https://github.com/imgix/imgix-python/pull/49))
## [3.0.0](https://github.com/imgix/imgix-python/compare/2.3.0...3.0.0) (2019-06-07)
- fix: remove deprecated domain sharding functionality
([\#44](https://github.com/imgix/imgix-python/pull/44))
- fix: remove deprecated [opts]{.title-ref} parameter
([\#46](https://github.com/imgix/imgix-python/pull/46))
- fix: remove deprecated [sign\_with\_library\_version]{.title-ref}
parameter ([\#47](https://github.com/imgix/imgix-python/pull/47))
## [2.3.0](https://github.com/imgix/imgix-python/compare/2.2.0...2.3.0) (2019-06-06)
- feat: deprecate [domains]{.title-ref} in favor of
[domain]{.title-ref}
([\#45](https://github.com/imgix/imgix-python/pull/45))
## [2.2.0](https://github.com/imgix/imgix-python/compare/2.1.0...2.2.0) (2019-05-07)
- deprecate domain sharding
([\#41](https://github.com/imgix/imgix-python/pull/41))([\#42](https://github.com/imgix/imgix-python/pull/42))
## 2.1.0 (2019-02-13)
- Domain validation added during [UrlBuilder]{.title-ref}
initialization
- [sign\_with\_library\_version]{.title-ref} parameter from
[UrlBuilder]{.title-ref} deprecated in favor of
[include\_library\_param]{.title-ref}.
## 2.0.0 (2018-08-08)
- [UrlBuilder]{.title-ref}\'s [sign\_mode]{.title-ref} argument
removed
- [opts]{.title-ref} parameter from
[UrlBuilder.create\_url]{.title-ref} deprecated in favor of
[params]{.title-ref}.
## 1.2.0 (2018-06-20)
- [sign\_mode]{.title-ref} argument deprecated
- License corrected to BSD-2-Clause.
- Docstrings added to classes and methods.
## 1.1.2 (2016-06-30)
- Proper encodeURIComponent-style URL encoding for web proxy sources.
See \#21 for more information.
## 1.1.0 (2016-02-26)
- Added automatic Base64 encoding for all Base64 variant parameters.
- Properly encoding all query keys and values.
## 1.0.0 (2016-01-15)
- Change UrlBuilder\#create_url to accept dict instead of kwargs.
This fixes an issue with reserved words that are also imgix params
potentially causing errors.
## 0.2.1 (2016-01-15)
- Fixed a bug where any passed params that were falsy would not be
passed through to imgix.
## 0.2.0 (2015-06-15)
- Introduces defaulting to HTTPS on all requests, per the
imgix-blueprint.
## 0.1.0 (2015-06-11)
- Includes new functionality to sign every URL with an ixlib parameter
for diagnostic purposes.
## 0.0.4 (2015-06-10)
- New README note about publishing packages
%package -n python3-imgix
Summary: Python client library for imgix.
Provides: python-imgix
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-imgix
<!-- /ix-docs-ignore -->
- [Installation](#installation)
- [Usage](#usage)
- [Signed URLs](#signed-urls)
- [Disabled Path Encoding](#disabled-path-encoding)
- [Srcset Generation](#srcset-generation)
* [Fixed-Width Images](#fixed-width-images)
+ [Variable Quality](#variable-quality)
* [Fluid-Width Images](#fluid-width-images)
+ [Custom Widths](#custom-widths)
+ [Width Ranges](#width-ranges)
+ [Width Tolerance](#width-tolerance)
+ [Explore Target Widths](#explore-target-widths)
* [Usage with UTF-8](#usage-with-utf-8)
- [The `ixlib` Parameter](#the-ixlib-parameter)
- [Testing](#testing)
- [License](#license)
## Installation
``` bash
pip install imgix
```
## Usage
To begin creating imgix URLs, import the imgix library and create a URL builder. The URL builder can be reused to create URLs for any images on the domains it is provided.
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net")
>>> ub.create_url("bridge.png", {'w': 100, 'h': 100})
'https://demo.imgix.net/bridge.png?h=100&w=100'
```
_HTTPS_ support is enabled by default. _HTTP_ can be toggled on by setting `use_https` to `False`:
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net", use_https=False)
>>> ub.create_url("/bridge.png", {'w': 100, 'h': 100})
'http://demo.imgix.net/bridge.png?h=100&w=100'
```
## Signed URLs
To produce a signed URL, you must enable secure URLs on your source and then provide your signature key to the URL builder.
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net", sign_key="test1234")
>>> ub.create_url("/bridge.png", {'w': 100, 'h': 100})
'https://demo.imgix.net/bridge.png?h=100&w=100&s=bb8f3a2ab832e35997456823272103a4'
```
## Disabled Path Encoding
Path encoding is enabled by default. It can be toggled off by setting `disable_path_encoding` to `True` in the optional `options` paramater in `create_url()` and `create_srcset()` functions:
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("sdk-test.imgix.net")
>>> ub.create_url(" <>[]{}|^%.jpg", params={'w': 100, 'h': 100}, options={'disable_path_encoding': True})
'https://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100'
```
Normally this would output a source URL like `https://demo.imgix.net/%20%3C%3E%5B%5D%7B%7D%7C%5E%25.jpg?h=100&2=100`, but since path encoding is disabled, it will output a source URL like `https://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100`.
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("sdk-test.imgix.net")
>>> ub.create_srcset("image<>[]{} 123.png", widths=[100], options={'disable_path_encoding': True})
'https://sdk-test.imgix.net/image<>[]{} 123.png?w=100 100w'
```
Normally this would output a source URL like `https://sdk-test.imgix.net/image%3C%3E%5B%5D%7B%7D%20123.png?&w=100 100w`, but since path encoding is disabled, it will output a source URL like `https://sdk-test.imgix.net//image<>[]{} 123.png?w=100 100w`.
## Srcset Generation
The imgix-python package allows for generation of custom srcset attributes, which can be invoked through the `create_srcset` method. By default, the generated srcset will allow for responsive size switching by building a list of image-width mappings.
``` python
import os
from imgix import UrlBuilder
# Keep Your Secrets Safe!
SECRET = os.getenv("IX_SIGN_KEY")
ub = UrlBuilder("demos.imgix.net", sign_key=SECRET)
srcset = ub.create_srcset("image.png")
```
The above will produce the following srcset attribute value which can then be served to the client:
``` html
https://demos.imgix.net/image.png?w=100&s=e415797545a77a9d2842dedcfe539c9a 100w,
https://demos.imgix.net/image.png?w=116&s=b2da46f5c23ef13d5da30f0a4545f33f 116w,
https://demos.imgix.net/image.png?w=135&s=b61422dead929f893c04b8ff839bb088 135w,
https://demos.imgix.net/image.png?w=7401&s=ad671301ed4663c3ce6e84cb646acb96 7401w,
https://demos.imgix.net/image.png?w=8192&s=a0fed46e2bbcc70ded13dc629aee5398 8192w
```
### Fixed-Width Images
In cases where enough information is provided about an image's dimensions, `create_srcset` will instead build a srcset that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are `w`, `h`, and `ar`.
By invoking `create_srcset` with either a width **or** the height and aspect ratio (along with `fit=crop`, typically) provided, a different srcset will be generated for a fixed-width image instead.
``` python
from imgix import UrlBuilder
>>> ub = UrlBuilder("demos.imgix.net", sign_key="my-token")
>>> srcset = ub.create_srcset("image.png", {'h':800, 'ar':'3:2', 'fit':'crop'})
```
Will produce the following attribute value:
``` html
https://demos.imgix.net/image.png?ar=3%3A2&dpr=1&fit=crop&h=800&s=6cf5c443d1eb98bc3d96ea569fcef088 1x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=2&fit=crop&h=800&s=d60a61a5f34545922bd8dff4e53a0555 2x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=3&fit=crop&h=800&s=590f96aa426f8589eb7e449ebbeb66e7 3x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=4&fit=crop&h=800&s=c89c2fd3148957647e86cfc32ba20517 4x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=5&fit=crop&h=800&s=3d73af69d78d49eef0f81b4b5d718a2c 5x
```
By default, this library generates a `srcset` with pixel density values of `1` through `5`.
These target ratios can be controlled by using the `devicePixelRatios` parameters.
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset(
"image.jpg",
{ "w": 100 },
{
"device_pixel_ratios": [ 1, 2, 3 ]
}
)
```
Will produce the following attribute value:
```html
https://demo.imgix.net/image.jpg?dpr=1&ixlib=python-3.2.1&q=75&w=100 1x,
https://demo.imgix.net/image.jpg?dpr=2&ixlib=python-3.2.1&q=50&w=100 2x,
https://demo.imgix.net/image.jpg?dpr=3&ixlib=python-3.2.1&q=35&w=100 3x'
```
For more information to better understand srcset, we highly recommend
[Eric Portis' "Srcset and sizes" article](https://ericportis.com/posts/2014/srcset-sizes/) which goes into depth about the subject.
#### Variable Quality
This library will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a [fixed-width image](#fixed-width-images) srcset. This technique is commonly used to compensate for the increased file size of high-DPR images.
Since high-DPR images are displayed at a higher pixel density on devices, image quality can be lowered to reduce overall file size––without sacrificing perceived visual quality. For more information and examples of this technique in action, see [this blog post](https://blog.imgix.com/2016/03/30/dpr-quality).
This behavior will respect any overriding `q` value passed in as a parameter. Additionally, it can be disabled altogether by passing `disable_variable_quality = true` to `create_srcset`.
This behavior specifically occurs when a [fixed-width image](#fixed-width-images) is rendered, for example:
```python
# Note that `params={"w": 100}` allows `create_srcset` to _infer_ the creation
# of a DPR based srcset attribute for fixed-width images.
ub = imgix.UrlBuilder('demo.imgix.net')
# Set `disable_variable_quality` to True to disable variable quality.
srcset = ub.create_srcset('image.jpg', params={"w": 100}, disable_variable_quality=False)
```
The above will generate a srcset with the following `q` to `dpr` query `params`:
```html
https://demo.imgix.net/image.jpg?w=100&dpr=1&q=75 1x,
https://demo.imgix.net/image.jpg?w=100&dpr=2&q=50 2x,
https://demo.imgix.net/image.jpg?w=100&dpr=3&q=35 3x,
https://demo.imgix.net/image.jpg?w=100&dpr=4&q=23 4x,
https://demo.imgix.net/image.jpg?w=100&dpr=5&q=20 5x
```
By default, this library will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a [fixed-width image](#fixed-width-images) srcset.
To customize variable qualities, you can pass a `variable_qualities` dictionary in the `options` while creating srcset as below:
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset("image.jpg", {"w": 100}, {"variable_qualities": {1: 45, 2: 30, 3: 20, 4: 15, 5: 10}})
```
The above script will produce the following output:
```bash
https://demo.imgix.net/image.jpg?dpr=1&q=45&w=100 1x
https://demo.imgix.net/image.jpg?dpr=2&q=30&w=100 2x
https://demo.imgix.net/image.jpg?dpr=3&q=20&w=100 3x
https://demo.imgix.net/image.jpg?dpr=4&&q=15&w=100 4x
https://demo.imgix.net/image.jpg?dpr=5&q=10&w=100 5x
```
You can also pass `variable_qualities` along with the `device_pixel_ratios` option as below:
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset(
"image.jpg",
{ "w": 100 },
{
"device_pixel_ratios": [ 1, 2, 3 ],
"variable_qualities": { 1: 45, 2: 30, 3: 20 }
}
)
```
The above script will produce the following output:
```html
https://testing.imgix.net/image.jpg?dpr=1&q=45&w=100 1x,
https://testing.imgix.net/image.jpg?dpr=2&q=30&w=100 2x,
https://testing.imgix.net/image.jpg?dpr=3&q=20&w=100 3x
```
### Fluid-Width Images
#### Custom Widths
In situations where specific widths are desired when generating `srcset` pairs, a user can specify them by passing an array of positive integers as `widths`:
``` python
>>> from imgix import UrlBuilder
>>> builder = UrlBuilder('demo.imgix.net')
>>> builder.create_srcset('image.jpg', widths=[144, 240, 320, 446, 640])
'https://demo.imgix.net/image.jpg?w=144 144w,\nhttps://demo.imgix.net/image.jpg?w=240 240w,\nhttps://demo.imgix.net/image.jpg?w=320 320w,\nhttps://demo.imgix.net/image.jpg?w=446 446w,\nhttps://demo.imgix.net/image.jpg?w=640 640w'
```
```html
https://demo.imgix.net/image.jpg?w=144 144w,
https://demo.imgix.net/image.jpg?w=240 240w,
https://demo.imgix.net/image.jpg?w=320 320w,
https://demo.imgix.net/image.jpg?w=446 446w,
https://demo.imgix.net/image.jpg?w=640 640w
```
**Note**: in situations where a `srcset` is being rendered as a [fixed-width](#fixed-width-images) srcset, any custom `widths` passed in will be ignored.
Additionally, if both `widths` and a width `tol`erance are passed to the `create_srcset` method, the custom widths list will take precedence.
#### Width Ranges
In certain circumstances, you may want to limit the minimum or maximum value of the non-fixed `srcset` generated by the `create_srcset` method. To do this, you can specify the widths at which a srcset should `start` and `stop`:
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder('demo.imgix.net')
>>> ub.create_srcset('image.jpg', start=500, stop=2000)
'https://demo.imgix.net/image.jpg?w=500 500w,\nhttps://demo.imgix.net/image.jpg?w=580 580w,\nhttps://demo.imgix.net/image.jpg?w=673 673w,\nhttps://demo.imgix.net/image.jpg?w=780 780w,\nhttps://demo.imgix.net/image.jpg?w=905 905w,\nhttps://demo.imgix.net/image.jpg?w=1050 1050w,\nhttps://demo.imgix.net/image.jpg?w=1218 1218w,\nhttps://demo.imgix.net/image.jpg?w=1413 1413w,\nhttps://demo.imgix.net/image.jpg?w=1639 1639w,\nhttps://demo.imgix.net/image.jpg?w=1901 1901w,\nhttps://demo.imgix.net/image.jpg?w=2000 2000w'
```
Formatted version of the above srcset attribute:
``` html
https://demo.imgix.net/image.jpg?w=500 500w,
https://demo.imgix.net/image.jpg?w=580 580w,
https://demo.imgix.net/image.jpg?w=673 673w,
https://demo.imgix.net/image.jpg?w=780 780w,
https://demo.imgix.net/image.jpg?w=905 905w,
https://demo.imgix.net/image.jpg?w=1050 1050w,
https://demo.imgix.net/image.jpg?w=1218 1218w,
https://demo.imgix.net/image.jpg?w=1413 1413w,
https://demo.imgix.net/image.jpg?w=1639 1639w,
https://demo.imgix.net/image.jpg?w=1901 1901w,
https://demo.imgix.net/image.jpg?w=2000 2000w'
```
#### Width Tolerance
The `srcset` width `tol`erance dictates the maximum `tol`erated difference between an image's downloaded size and its rendered size.
For example, setting this value to `0.10` means that an image will not render more than 10% larger or smaller than its native size. In practice, the image URLs generated for a width-based srcset attribute will grow by twice this rate.
A lower tolerance means images will render closer to their native size (thereby increasing perceived image quality), but a large srcset list will be generated and consequently users may experience lower rates of cache-hit for pre-rendered images on your site.
By default, srcset width `tol`erance is set to 0.08 (8 percent), which we consider to be the ideal rate for maximizing cache hits without sacrificing visual quality. Users can specify their own width tolerance by providing a positive scalar value as width `tol`erance:
```python
>>> import imgix
>>> ub = imgix.UrlBuilder('demo.imgix.net')
>>> srcset = ub.create_srcset('image.jpg', start=100, stop=384, tol=0.20)
```
In this case, the `width_tolerance` is set to 20 percent, which will be reflected in the difference between subsequent widths in a srcset pair:
```html
https://demo.imgix.net/image.jpg?w=100 100w,
https://demo.imgix.net/image.jpg?w=140 140w,
https://demo.imgix.net/image.jpg?w=196 196w,
https://demo.imgix.net/image.jpg?w=274 274w,
https://demo.imgix.net/image.jpg?w=384 384w
```
#### Explore Target Widths
The `target_widths` function is used internally to generate lists of target widths to be used in calls to `create_srcset`.
It is a way to generate, play with, and explore different target widths separately from srcset attributes. One way of generating a srcset attribute is:
```python
srcset = ub.create_srcset('image.jpg', start=300, stop=3000, tol=0.13)
```
The above is convenient if `start`, `stop`, and `tol`erance are known in advance. Another approach is to use `target_widths` to determine which combination of values for `start`, `stop`, and `tol`erance work best.
```python
>>> from imgix import UrlBuilder, target_widths
>>> # Create
>>> widths = target_widths(300, 3000, 0.13)
>>> widths
[300, 378, 476, 600, 756, 953, 1200, 1513, 1906, 2401, 3000]
>>> # Explore
>>> sm, md, lg = widths[:3], widths[3:7], widths[7:]
>>> widths = [w for w in widths[1::2]]
>>> widths
[378, 600, 953, 1513, 2401]
>>> # Serve
>>> ub = UrlBuilder('demo.imgix.net')
>>> srcset = ub.create_srcset('image.png', widths=widths)
>>> srcset
'https://demo.imgix.net/image.png?w=378 378w,\nhttps://demo.imgix.net/image.png?w=600 600w,\nhttps://demo.imgix.net/image.png?w=953 953w,\nhttps://demo.imgix.net/image.png?w=1513 1513w,\nhttps://demo.imgix.net/image.png?w=2401 2401w'
```
### Usage with UTF-8
For usage with non-ASCII characters, please be sure that your project's source files specify UTF-8 encoding:
``` python
# -*- coding: utf-8 -*-
```
If you don't add this encoding, and you have an image with the name 'tiburón.jpeg', for example, you will get the following error trying to run your script:
``` python
SyntaxError: Non-ASCII character '***' in file test.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
```
## The `ixlib` Parameter
For security and diagnostic purposes, we sign all requests with the language and version of library used to generate the URL.
This can be disabled by setting `include_library_param` to `False` like so:
``` python
UrlBuilder('demo.imgix.net', include_library_param=False)
```
## Testing
Run the following to execute the project's tests and code linter:
``` bash
tox
```
If you have cloned this repo or downloaded it locally, you can also run `python -m doctest -v README.md` to test the examples in this readme.
## License
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-python?ref=badge_large)
# Changelog
## [4.0.0](https://github.com/imgix/imgix-python/compare/3.2.1...4.0.0) (2022-12-08)
### Breaking Changes
- feat: drop python 2 support ([#88](https://github.com/imgix/imgix-python/pull/88))
- fix: fixed-height produces dpr-based srcset ([#88](https://github.com/imgix/imgix-python/pull/88))
- feat: encode file path components ([#88](https://github.com/imgix/imgix-python/pull/88))
### Features
- feat: add path encoding to be disabled optionally ([#98](https://github.com/imgix/imgix-python/pull/98))
- feat: customize variable qualities in options ([#102](https://github.com/imgix/imgix-python/pull/102))
- feat: customize target device pixel ratios ([#103](https://github.com/imgix/imgix-python/pull/103))
## [3.2.1](https://github.com/imgix/imgix-python/compare/3.2.0...3.2.1) (2020-06-10)
- refactor: relax validation for min/max width values ([#80](https://github.com/imgix/imgix-python/pull/80))
## [3.2.0](https://github.com/imgix/imgix-python/compare/3.1.2...3.2.0) (2020-06-05)
- feat: create custom srcset ([#63](https://github.com/imgix/imgix-python/pull/63))
- feat: introduce variable image output quality ([#65](https://github.com/imgix/imgix-python/pull/65))
- fix: remove ensure even ([#72](https://github.com/imgix/imgix-python/pull/72))
- feat: throw exceptions from validators ([#77](https://github.com/imgix/imgix-python/pull/77))
- fix: convert tol to float ([#75](https://github.com/imgix/imgix-python/pull/75))
## [3.1.2](https://github.com/imgix/imgix-python/compare/3.1.1...3.1.2) (2020-03-11)
- Fix Python 2/3 compatibility issues
([\#57](https://github.com/imgix/imgix-python/pull/57))
## [3.1.1](https://github.com/imgix/imgix-python/compare/3.1.0...3.1.1) (2019-08-22)
- fix: include dpr parameter when generating fixed-width srcset
([\#50](https://github.com/imgix/imgix-python/pull/50))
## [3.1.0](https://github.com/imgix/imgix-python/compare/3.0.0...3.1.0) (2019-08-22)
- feat: add srcset generation
([\#48](https://github.com/imgix/imgix-python/pull/48))
- build(tox): improve code coverage reporting; parallelize testing
([\#49](https://github.com/imgix/imgix-python/pull/49))
## [3.0.0](https://github.com/imgix/imgix-python/compare/2.3.0...3.0.0) (2019-06-07)
- fix: remove deprecated domain sharding functionality
([\#44](https://github.com/imgix/imgix-python/pull/44))
- fix: remove deprecated [opts]{.title-ref} parameter
([\#46](https://github.com/imgix/imgix-python/pull/46))
- fix: remove deprecated [sign\_with\_library\_version]{.title-ref}
parameter ([\#47](https://github.com/imgix/imgix-python/pull/47))
## [2.3.0](https://github.com/imgix/imgix-python/compare/2.2.0...2.3.0) (2019-06-06)
- feat: deprecate [domains]{.title-ref} in favor of
[domain]{.title-ref}
([\#45](https://github.com/imgix/imgix-python/pull/45))
## [2.2.0](https://github.com/imgix/imgix-python/compare/2.1.0...2.2.0) (2019-05-07)
- deprecate domain sharding
([\#41](https://github.com/imgix/imgix-python/pull/41))([\#42](https://github.com/imgix/imgix-python/pull/42))
## 2.1.0 (2019-02-13)
- Domain validation added during [UrlBuilder]{.title-ref}
initialization
- [sign\_with\_library\_version]{.title-ref} parameter from
[UrlBuilder]{.title-ref} deprecated in favor of
[include\_library\_param]{.title-ref}.
## 2.0.0 (2018-08-08)
- [UrlBuilder]{.title-ref}\'s [sign\_mode]{.title-ref} argument
removed
- [opts]{.title-ref} parameter from
[UrlBuilder.create\_url]{.title-ref} deprecated in favor of
[params]{.title-ref}.
## 1.2.0 (2018-06-20)
- [sign\_mode]{.title-ref} argument deprecated
- License corrected to BSD-2-Clause.
- Docstrings added to classes and methods.
## 1.1.2 (2016-06-30)
- Proper encodeURIComponent-style URL encoding for web proxy sources.
See \#21 for more information.
## 1.1.0 (2016-02-26)
- Added automatic Base64 encoding for all Base64 variant parameters.
- Properly encoding all query keys and values.
## 1.0.0 (2016-01-15)
- Change UrlBuilder\#create_url to accept dict instead of kwargs.
This fixes an issue with reserved words that are also imgix params
potentially causing errors.
## 0.2.1 (2016-01-15)
- Fixed a bug where any passed params that were falsy would not be
passed through to imgix.
## 0.2.0 (2015-06-15)
- Introduces defaulting to HTTPS on all requests, per the
imgix-blueprint.
## 0.1.0 (2015-06-11)
- Includes new functionality to sign every URL with an ixlib parameter
for diagnostic purposes.
## 0.0.4 (2015-06-10)
- New README note about publishing packages
%package help
Summary: Development documents and examples for imgix
Provides: python3-imgix-doc
%description help
<!-- /ix-docs-ignore -->
- [Installation](#installation)
- [Usage](#usage)
- [Signed URLs](#signed-urls)
- [Disabled Path Encoding](#disabled-path-encoding)
- [Srcset Generation](#srcset-generation)
* [Fixed-Width Images](#fixed-width-images)
+ [Variable Quality](#variable-quality)
* [Fluid-Width Images](#fluid-width-images)
+ [Custom Widths](#custom-widths)
+ [Width Ranges](#width-ranges)
+ [Width Tolerance](#width-tolerance)
+ [Explore Target Widths](#explore-target-widths)
* [Usage with UTF-8](#usage-with-utf-8)
- [The `ixlib` Parameter](#the-ixlib-parameter)
- [Testing](#testing)
- [License](#license)
## Installation
``` bash
pip install imgix
```
## Usage
To begin creating imgix URLs, import the imgix library and create a URL builder. The URL builder can be reused to create URLs for any images on the domains it is provided.
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net")
>>> ub.create_url("bridge.png", {'w': 100, 'h': 100})
'https://demo.imgix.net/bridge.png?h=100&w=100'
```
_HTTPS_ support is enabled by default. _HTTP_ can be toggled on by setting `use_https` to `False`:
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net", use_https=False)
>>> ub.create_url("/bridge.png", {'w': 100, 'h': 100})
'http://demo.imgix.net/bridge.png?h=100&w=100'
```
## Signed URLs
To produce a signed URL, you must enable secure URLs on your source and then provide your signature key to the URL builder.
``` python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("demo.imgix.net", sign_key="test1234")
>>> ub.create_url("/bridge.png", {'w': 100, 'h': 100})
'https://demo.imgix.net/bridge.png?h=100&w=100&s=bb8f3a2ab832e35997456823272103a4'
```
## Disabled Path Encoding
Path encoding is enabled by default. It can be toggled off by setting `disable_path_encoding` to `True` in the optional `options` paramater in `create_url()` and `create_srcset()` functions:
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("sdk-test.imgix.net")
>>> ub.create_url(" <>[]{}|^%.jpg", params={'w': 100, 'h': 100}, options={'disable_path_encoding': True})
'https://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100'
```
Normally this would output a source URL like `https://demo.imgix.net/%20%3C%3E%5B%5D%7B%7D%7C%5E%25.jpg?h=100&2=100`, but since path encoding is disabled, it will output a source URL like `https://sdk-test.imgix.net/ <>[]{}|^%.jpg?h=100&w=100`.
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder("sdk-test.imgix.net")
>>> ub.create_srcset("image<>[]{} 123.png", widths=[100], options={'disable_path_encoding': True})
'https://sdk-test.imgix.net/image<>[]{} 123.png?w=100 100w'
```
Normally this would output a source URL like `https://sdk-test.imgix.net/image%3C%3E%5B%5D%7B%7D%20123.png?&w=100 100w`, but since path encoding is disabled, it will output a source URL like `https://sdk-test.imgix.net//image<>[]{} 123.png?w=100 100w`.
## Srcset Generation
The imgix-python package allows for generation of custom srcset attributes, which can be invoked through the `create_srcset` method. By default, the generated srcset will allow for responsive size switching by building a list of image-width mappings.
``` python
import os
from imgix import UrlBuilder
# Keep Your Secrets Safe!
SECRET = os.getenv("IX_SIGN_KEY")
ub = UrlBuilder("demos.imgix.net", sign_key=SECRET)
srcset = ub.create_srcset("image.png")
```
The above will produce the following srcset attribute value which can then be served to the client:
``` html
https://demos.imgix.net/image.png?w=100&s=e415797545a77a9d2842dedcfe539c9a 100w,
https://demos.imgix.net/image.png?w=116&s=b2da46f5c23ef13d5da30f0a4545f33f 116w,
https://demos.imgix.net/image.png?w=135&s=b61422dead929f893c04b8ff839bb088 135w,
https://demos.imgix.net/image.png?w=7401&s=ad671301ed4663c3ce6e84cb646acb96 7401w,
https://demos.imgix.net/image.png?w=8192&s=a0fed46e2bbcc70ded13dc629aee5398 8192w
```
### Fixed-Width Images
In cases where enough information is provided about an image's dimensions, `create_srcset` will instead build a srcset that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are `w`, `h`, and `ar`.
By invoking `create_srcset` with either a width **or** the height and aspect ratio (along with `fit=crop`, typically) provided, a different srcset will be generated for a fixed-width image instead.
``` python
from imgix import UrlBuilder
>>> ub = UrlBuilder("demos.imgix.net", sign_key="my-token")
>>> srcset = ub.create_srcset("image.png", {'h':800, 'ar':'3:2', 'fit':'crop'})
```
Will produce the following attribute value:
``` html
https://demos.imgix.net/image.png?ar=3%3A2&dpr=1&fit=crop&h=800&s=6cf5c443d1eb98bc3d96ea569fcef088 1x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=2&fit=crop&h=800&s=d60a61a5f34545922bd8dff4e53a0555 2x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=3&fit=crop&h=800&s=590f96aa426f8589eb7e449ebbeb66e7 3x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=4&fit=crop&h=800&s=c89c2fd3148957647e86cfc32ba20517 4x,
https://demos.imgix.net/image.png?ar=3%3A2&dpr=5&fit=crop&h=800&s=3d73af69d78d49eef0f81b4b5d718a2c 5x
```
By default, this library generates a `srcset` with pixel density values of `1` through `5`.
These target ratios can be controlled by using the `devicePixelRatios` parameters.
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset(
"image.jpg",
{ "w": 100 },
{
"device_pixel_ratios": [ 1, 2, 3 ]
}
)
```
Will produce the following attribute value:
```html
https://demo.imgix.net/image.jpg?dpr=1&ixlib=python-3.2.1&q=75&w=100 1x,
https://demo.imgix.net/image.jpg?dpr=2&ixlib=python-3.2.1&q=50&w=100 2x,
https://demo.imgix.net/image.jpg?dpr=3&ixlib=python-3.2.1&q=35&w=100 3x'
```
For more information to better understand srcset, we highly recommend
[Eric Portis' "Srcset and sizes" article](https://ericportis.com/posts/2014/srcset-sizes/) which goes into depth about the subject.
#### Variable Quality
This library will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a [fixed-width image](#fixed-width-images) srcset. This technique is commonly used to compensate for the increased file size of high-DPR images.
Since high-DPR images are displayed at a higher pixel density on devices, image quality can be lowered to reduce overall file size––without sacrificing perceived visual quality. For more information and examples of this technique in action, see [this blog post](https://blog.imgix.com/2016/03/30/dpr-quality).
This behavior will respect any overriding `q` value passed in as a parameter. Additionally, it can be disabled altogether by passing `disable_variable_quality = true` to `create_srcset`.
This behavior specifically occurs when a [fixed-width image](#fixed-width-images) is rendered, for example:
```python
# Note that `params={"w": 100}` allows `create_srcset` to _infer_ the creation
# of a DPR based srcset attribute for fixed-width images.
ub = imgix.UrlBuilder('demo.imgix.net')
# Set `disable_variable_quality` to True to disable variable quality.
srcset = ub.create_srcset('image.jpg', params={"w": 100}, disable_variable_quality=False)
```
The above will generate a srcset with the following `q` to `dpr` query `params`:
```html
https://demo.imgix.net/image.jpg?w=100&dpr=1&q=75 1x,
https://demo.imgix.net/image.jpg?w=100&dpr=2&q=50 2x,
https://demo.imgix.net/image.jpg?w=100&dpr=3&q=35 3x,
https://demo.imgix.net/image.jpg?w=100&dpr=4&q=23 4x,
https://demo.imgix.net/image.jpg?w=100&dpr=5&q=20 5x
```
By default, this library will automatically append a variable `q` parameter mapped to each `dpr` parameter when generating a [fixed-width image](#fixed-width-images) srcset.
To customize variable qualities, you can pass a `variable_qualities` dictionary in the `options` while creating srcset as below:
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset("image.jpg", {"w": 100}, {"variable_qualities": {1: 45, 2: 30, 3: 20, 4: 15, 5: 10}})
```
The above script will produce the following output:
```bash
https://demo.imgix.net/image.jpg?dpr=1&q=45&w=100 1x
https://demo.imgix.net/image.jpg?dpr=2&q=30&w=100 2x
https://demo.imgix.net/image.jpg?dpr=3&q=20&w=100 3x
https://demo.imgix.net/image.jpg?dpr=4&&q=15&w=100 4x
https://demo.imgix.net/image.jpg?dpr=5&q=10&w=100 5x
```
You can also pass `variable_qualities` along with the `device_pixel_ratios` option as below:
```python
from imgix import UrlBuilder
client = UrlBuilder("demo.imgix.net")
client.create_srcset(
"image.jpg",
{ "w": 100 },
{
"device_pixel_ratios": [ 1, 2, 3 ],
"variable_qualities": { 1: 45, 2: 30, 3: 20 }
}
)
```
The above script will produce the following output:
```html
https://testing.imgix.net/image.jpg?dpr=1&q=45&w=100 1x,
https://testing.imgix.net/image.jpg?dpr=2&q=30&w=100 2x,
https://testing.imgix.net/image.jpg?dpr=3&q=20&w=100 3x
```
### Fluid-Width Images
#### Custom Widths
In situations where specific widths are desired when generating `srcset` pairs, a user can specify them by passing an array of positive integers as `widths`:
``` python
>>> from imgix import UrlBuilder
>>> builder = UrlBuilder('demo.imgix.net')
>>> builder.create_srcset('image.jpg', widths=[144, 240, 320, 446, 640])
'https://demo.imgix.net/image.jpg?w=144 144w,\nhttps://demo.imgix.net/image.jpg?w=240 240w,\nhttps://demo.imgix.net/image.jpg?w=320 320w,\nhttps://demo.imgix.net/image.jpg?w=446 446w,\nhttps://demo.imgix.net/image.jpg?w=640 640w'
```
```html
https://demo.imgix.net/image.jpg?w=144 144w,
https://demo.imgix.net/image.jpg?w=240 240w,
https://demo.imgix.net/image.jpg?w=320 320w,
https://demo.imgix.net/image.jpg?w=446 446w,
https://demo.imgix.net/image.jpg?w=640 640w
```
**Note**: in situations where a `srcset` is being rendered as a [fixed-width](#fixed-width-images) srcset, any custom `widths` passed in will be ignored.
Additionally, if both `widths` and a width `tol`erance are passed to the `create_srcset` method, the custom widths list will take precedence.
#### Width Ranges
In certain circumstances, you may want to limit the minimum or maximum value of the non-fixed `srcset` generated by the `create_srcset` method. To do this, you can specify the widths at which a srcset should `start` and `stop`:
```python
>>> from imgix import UrlBuilder
>>> ub = UrlBuilder('demo.imgix.net')
>>> ub.create_srcset('image.jpg', start=500, stop=2000)
'https://demo.imgix.net/image.jpg?w=500 500w,\nhttps://demo.imgix.net/image.jpg?w=580 580w,\nhttps://demo.imgix.net/image.jpg?w=673 673w,\nhttps://demo.imgix.net/image.jpg?w=780 780w,\nhttps://demo.imgix.net/image.jpg?w=905 905w,\nhttps://demo.imgix.net/image.jpg?w=1050 1050w,\nhttps://demo.imgix.net/image.jpg?w=1218 1218w,\nhttps://demo.imgix.net/image.jpg?w=1413 1413w,\nhttps://demo.imgix.net/image.jpg?w=1639 1639w,\nhttps://demo.imgix.net/image.jpg?w=1901 1901w,\nhttps://demo.imgix.net/image.jpg?w=2000 2000w'
```
Formatted version of the above srcset attribute:
``` html
https://demo.imgix.net/image.jpg?w=500 500w,
https://demo.imgix.net/image.jpg?w=580 580w,
https://demo.imgix.net/image.jpg?w=673 673w,
https://demo.imgix.net/image.jpg?w=780 780w,
https://demo.imgix.net/image.jpg?w=905 905w,
https://demo.imgix.net/image.jpg?w=1050 1050w,
https://demo.imgix.net/image.jpg?w=1218 1218w,
https://demo.imgix.net/image.jpg?w=1413 1413w,
https://demo.imgix.net/image.jpg?w=1639 1639w,
https://demo.imgix.net/image.jpg?w=1901 1901w,
https://demo.imgix.net/image.jpg?w=2000 2000w'
```
#### Width Tolerance
The `srcset` width `tol`erance dictates the maximum `tol`erated difference between an image's downloaded size and its rendered size.
For example, setting this value to `0.10` means that an image will not render more than 10% larger or smaller than its native size. In practice, the image URLs generated for a width-based srcset attribute will grow by twice this rate.
A lower tolerance means images will render closer to their native size (thereby increasing perceived image quality), but a large srcset list will be generated and consequently users may experience lower rates of cache-hit for pre-rendered images on your site.
By default, srcset width `tol`erance is set to 0.08 (8 percent), which we consider to be the ideal rate for maximizing cache hits without sacrificing visual quality. Users can specify their own width tolerance by providing a positive scalar value as width `tol`erance:
```python
>>> import imgix
>>> ub = imgix.UrlBuilder('demo.imgix.net')
>>> srcset = ub.create_srcset('image.jpg', start=100, stop=384, tol=0.20)
```
In this case, the `width_tolerance` is set to 20 percent, which will be reflected in the difference between subsequent widths in a srcset pair:
```html
https://demo.imgix.net/image.jpg?w=100 100w,
https://demo.imgix.net/image.jpg?w=140 140w,
https://demo.imgix.net/image.jpg?w=196 196w,
https://demo.imgix.net/image.jpg?w=274 274w,
https://demo.imgix.net/image.jpg?w=384 384w
```
#### Explore Target Widths
The `target_widths` function is used internally to generate lists of target widths to be used in calls to `create_srcset`.
It is a way to generate, play with, and explore different target widths separately from srcset attributes. One way of generating a srcset attribute is:
```python
srcset = ub.create_srcset('image.jpg', start=300, stop=3000, tol=0.13)
```
The above is convenient if `start`, `stop`, and `tol`erance are known in advance. Another approach is to use `target_widths` to determine which combination of values for `start`, `stop`, and `tol`erance work best.
```python
>>> from imgix import UrlBuilder, target_widths
>>> # Create
>>> widths = target_widths(300, 3000, 0.13)
>>> widths
[300, 378, 476, 600, 756, 953, 1200, 1513, 1906, 2401, 3000]
>>> # Explore
>>> sm, md, lg = widths[:3], widths[3:7], widths[7:]
>>> widths = [w for w in widths[1::2]]
>>> widths
[378, 600, 953, 1513, 2401]
>>> # Serve
>>> ub = UrlBuilder('demo.imgix.net')
>>> srcset = ub.create_srcset('image.png', widths=widths)
>>> srcset
'https://demo.imgix.net/image.png?w=378 378w,\nhttps://demo.imgix.net/image.png?w=600 600w,\nhttps://demo.imgix.net/image.png?w=953 953w,\nhttps://demo.imgix.net/image.png?w=1513 1513w,\nhttps://demo.imgix.net/image.png?w=2401 2401w'
```
### Usage with UTF-8
For usage with non-ASCII characters, please be sure that your project's source files specify UTF-8 encoding:
``` python
# -*- coding: utf-8 -*-
```
If you don't add this encoding, and you have an image with the name 'tiburón.jpeg', for example, you will get the following error trying to run your script:
``` python
SyntaxError: Non-ASCII character '***' in file test.py on line 6, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
```
## The `ixlib` Parameter
For security and diagnostic purposes, we sign all requests with the language and version of library used to generate the URL.
This can be disabled by setting `include_library_param` to `False` like so:
``` python
UrlBuilder('demo.imgix.net', include_library_param=False)
```
## Testing
Run the following to execute the project's tests and code linter:
``` bash
tox
```
If you have cloned this repo or downloaded it locally, you can also run `python -m doctest -v README.md` to test the examples in this readme.
## License
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fimgix%2Fimgix-python?ref=badge_large)
# Changelog
## [4.0.0](https://github.com/imgix/imgix-python/compare/3.2.1...4.0.0) (2022-12-08)
### Breaking Changes
- feat: drop python 2 support ([#88](https://github.com/imgix/imgix-python/pull/88))
- fix: fixed-height produces dpr-based srcset ([#88](https://github.com/imgix/imgix-python/pull/88))
- feat: encode file path components ([#88](https://github.com/imgix/imgix-python/pull/88))
### Features
- feat: add path encoding to be disabled optionally ([#98](https://github.com/imgix/imgix-python/pull/98))
- feat: customize variable qualities in options ([#102](https://github.com/imgix/imgix-python/pull/102))
- feat: customize target device pixel ratios ([#103](https://github.com/imgix/imgix-python/pull/103))
## [3.2.1](https://github.com/imgix/imgix-python/compare/3.2.0...3.2.1) (2020-06-10)
- refactor: relax validation for min/max width values ([#80](https://github.com/imgix/imgix-python/pull/80))
## [3.2.0](https://github.com/imgix/imgix-python/compare/3.1.2...3.2.0) (2020-06-05)
- feat: create custom srcset ([#63](https://github.com/imgix/imgix-python/pull/63))
- feat: introduce variable image output quality ([#65](https://github.com/imgix/imgix-python/pull/65))
- fix: remove ensure even ([#72](https://github.com/imgix/imgix-python/pull/72))
- feat: throw exceptions from validators ([#77](https://github.com/imgix/imgix-python/pull/77))
- fix: convert tol to float ([#75](https://github.com/imgix/imgix-python/pull/75))
## [3.1.2](https://github.com/imgix/imgix-python/compare/3.1.1...3.1.2) (2020-03-11)
- Fix Python 2/3 compatibility issues
([\#57](https://github.com/imgix/imgix-python/pull/57))
## [3.1.1](https://github.com/imgix/imgix-python/compare/3.1.0...3.1.1) (2019-08-22)
- fix: include dpr parameter when generating fixed-width srcset
([\#50](https://github.com/imgix/imgix-python/pull/50))
## [3.1.0](https://github.com/imgix/imgix-python/compare/3.0.0...3.1.0) (2019-08-22)
- feat: add srcset generation
([\#48](https://github.com/imgix/imgix-python/pull/48))
- build(tox): improve code coverage reporting; parallelize testing
([\#49](https://github.com/imgix/imgix-python/pull/49))
## [3.0.0](https://github.com/imgix/imgix-python/compare/2.3.0...3.0.0) (2019-06-07)
- fix: remove deprecated domain sharding functionality
([\#44](https://github.com/imgix/imgix-python/pull/44))
- fix: remove deprecated [opts]{.title-ref} parameter
([\#46](https://github.com/imgix/imgix-python/pull/46))
- fix: remove deprecated [sign\_with\_library\_version]{.title-ref}
parameter ([\#47](https://github.com/imgix/imgix-python/pull/47))
## [2.3.0](https://github.com/imgix/imgix-python/compare/2.2.0...2.3.0) (2019-06-06)
- feat: deprecate [domains]{.title-ref} in favor of
[domain]{.title-ref}
([\#45](https://github.com/imgix/imgix-python/pull/45))
## [2.2.0](https://github.com/imgix/imgix-python/compare/2.1.0...2.2.0) (2019-05-07)
- deprecate domain sharding
([\#41](https://github.com/imgix/imgix-python/pull/41))([\#42](https://github.com/imgix/imgix-python/pull/42))
## 2.1.0 (2019-02-13)
- Domain validation added during [UrlBuilder]{.title-ref}
initialization
- [sign\_with\_library\_version]{.title-ref} parameter from
[UrlBuilder]{.title-ref} deprecated in favor of
[include\_library\_param]{.title-ref}.
## 2.0.0 (2018-08-08)
- [UrlBuilder]{.title-ref}\'s [sign\_mode]{.title-ref} argument
removed
- [opts]{.title-ref} parameter from
[UrlBuilder.create\_url]{.title-ref} deprecated in favor of
[params]{.title-ref}.
## 1.2.0 (2018-06-20)
- [sign\_mode]{.title-ref} argument deprecated
- License corrected to BSD-2-Clause.
- Docstrings added to classes and methods.
## 1.1.2 (2016-06-30)
- Proper encodeURIComponent-style URL encoding for web proxy sources.
See \#21 for more information.
## 1.1.0 (2016-02-26)
- Added automatic Base64 encoding for all Base64 variant parameters.
- Properly encoding all query keys and values.
## 1.0.0 (2016-01-15)
- Change UrlBuilder\#create_url to accept dict instead of kwargs.
This fixes an issue with reserved words that are also imgix params
potentially causing errors.
## 0.2.1 (2016-01-15)
- Fixed a bug where any passed params that were falsy would not be
passed through to imgix.
## 0.2.0 (2015-06-15)
- Introduces defaulting to HTTPS on all requests, per the
imgix-blueprint.
## 0.1.0 (2015-06-11)
- Includes new functionality to sign every URL with an ixlib parameter
for diagnostic purposes.
## 0.0.4 (2015-06-10)
- New README note about publishing packages
%prep
%autosetup -n imgix-4.0.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-imgix -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 4.0.0-1
- Package Spec generated
|