@@ -1688,7 +1688,7 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
1688
1688
1689
1689
1690
1690
Name : image-rendering
1691
- Value : auto | smooth | high-quality | crisp-edges | pixelated
1691
+ Value : auto | smooth | high-quality | pixelated | crisp-edges
1692
1692
Initial : auto
1693
1693
Applies to : all elements
1694
1694
Inherited : yes
@@ -1743,33 +1743,28 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
1743
1743
pixelated
1744
1744
1745
1745
The image is scaled in a way that preserves the pixelated nature of the original as much as possible,
1746
- but allows minor smoothing instead of awkward distortion in some cases .
1746
+ but allows minor smoothing instead of awkward distortion when necessary .
1747
1747
1748
1748
For each axis,
1749
1749
independently determine the integer multiple of its natural size
1750
1750
that puts it closest to the target size
1751
1751
and is greater than zero.
1752
1752
1753
- Scale it to this integer-multiple-size as for ''nearest-neighbor '' ,
1753
+ Scale it to this integer-multiple-size as for ''crisp-edges '' ,
1754
1754
then scale it the rest of the way to the target size as for ''smooth'' .
1755
1755
1756
1756
Note: At integer multiples of the natural size,
1757
- this gives the same results as ''nearest-neighbor '' .
1757
+ this gives the same results as ''crisp-edges '' .
1758
1758
At non-integer multiples, this usually gives better visual results,
1759
1759
even for pixel art,
1760
1760
but it does incur a performance penalty
1761
1761
due to the "two-step" rendering requirement.
1762
1762
1763
1763
crisp-edges
1764
1764
1765
- The image must be scaled with an algorithm that preserves contrast and edges in the image ,
1765
+ The image is scaled in a way that preserves contrast and edges,
1766
1766
and which does not smooth colors or introduce blur to the image in the process.
1767
1767
1768
- This may be identical to ''nearest-neighbor'' ,
1769
- but UAs may use any algorithm that meets the requirements.
1770
-
1771
- nearest-neighbor
1772
-
1773
1768
The image must be scaled with the "nearest neighbor" algorithm:
1774
1769
treating the original image's pixel grid as a literal grid of rectangles,
1775
1770
scale those to the desired size,
@@ -1779,56 +1774,81 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
1779
1774
Note: If the new size is not an integer multiple of the original size,
1780
1775
the NN algorithm can introduce significant "aliasing" bugs;
1781
1776
lines that were the same thickness in the original image
1782
- might be a pixel thinner or thicker in the scaled image,
1777
+ might be a pixel thinner or thicker in the scaled image
1783
1778
depending on where they appear,
1784
1779
etc.
1785
1780
1786
1781
1787
- This property does not dictate any particular scaling algorithm to be used.
1782
+ Other than ''crisp-edges''
1783
+ and the portion of ''pixelated'' that acts like ''crisp-edges'' ,
1784
+ this property does not dictate any particular scaling algorithm to be used.
1788
1785
For example, with ''image-rendering: auto'' ,
1789
1786
a user agent might scale images with bilinear interpolation by default,
1790
1787
switch to nearest-neighbor interpolation in high-load situations,
1791
- and switch to a high-quality scaling algorithm like Lanczos interpolation for static images that aren't moving or changing.
1792
- Similarly, with 'image-rendering: crisp-edges' ,
1793
- a user agent might scale images with nearest-neighbor interpolation by default,
1794
- and switch to EPX interpolation in low-load situations.
1788
+ and switch to a high-quality scaling algorithm like Lanczos interpolation
1789
+ for static images that aren't moving or changing.
1795
1790
1796
1791
1797
1792
For example, given the following small image:
1798
1793
1799
1794
1800
1795
1801
- A small pixel-art image.
1796
+ A small pixel-art image.
1802
1797
1803
1798
1804
1799
Scaling it up 3x might look like the following,
1805
1800
depending on the value of 'image-rendering' :
1806
1801
1807
1802
1808
1803
1809
- The image scaled with ''image-rendering/auto ''
1804
+ The image scaled with ''smooth ''
1810
1805
1811
1806
1812
1807
1813
1808
1814
- The image scaled with ''pixelated''
1809
+ The image scaled with ''pixelated'' or ''crisp-edges''
1810
+
1811
+
1812
+
1813
+
1814
+ At the 3x scaling as in the preceding example,
1815
+ ''pixelated'' and ''crisp-edges'' give identical results.
1816
+ At scale ratios in-between integer multiples,
1817
+ however,
1818
+ they'll act differently:
1819
+
1820
+
1821
+
1822
+ The same small pixel-art image as before.
1823
+
1824
+
1825
+
1826
+
1827
+ The image scaled 2.5x with ''smooth''
1815
1828
1816
1829
1817
1830
1818
-
1819
-
1820
- The image scaled with ''crisp-edges'' .
1821
- (Or it might look like ''nearest-neighbor'' ,
1822
- or as another type of pixel-scaling algorithm,
1823
- depending on the browser.)
1824
-
1831
+
1832
+ The image scaled 2.5x with ''pixelated''
1825
1833
1834
+
1835
+
1836
+
1837
+ The image scaled 2.5x with ''crisp-edges''
1838
+
1839
+
1840
+ The ''pixelated'' version maintains the overall look of simply scaling the pixels up,
1841
+ at the cost of slight blurring,
1842
+ tho much less blurring than the ''smooth'' scaling gives.
1843
+ Meanwhile, ''crisp-edges'' avoids introducing any blurring at all,
1844
+ at the cost of aliasing artifacts
1845
+ making the "pixels" look irregularly sized.
1826
1846
1827
1847
1828
1848
This property previously accepted the values ''optimizeSpeed'' and ''optimizeQuality'' .
1829
1849
These are now deprecated;
1830
1850
a user agent must accept them as valid values
1831
- but must treat them as having the same behavior as ''nearest-neighbor '' and ''smooth'' respectively,
1851
+ but must treat them as having the same behavior as ''crisp-edges '' and ''smooth'' respectively,
1832
1852
and authors must not use them.
1833
1853
1834
1854
0 commit comments