@@ -1688,7 +1688,7 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
16881688
16891689 <pre class='propdef'>
16901690 Name : image-rendering
1691- Value : auto | smooth | high-quality | crisp-edges | pixelated
1691+ Value : auto | smooth | high-quality | pixelated | crisp-edges
16921692 Initial : auto
16931693 Applies to : all elements
16941694 Inherited : yes
@@ -1743,33 +1743,28 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
17431743 <dt> <dfn>pixelated</dfn>
17441744 <dd>
17451745 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 .
17471747
17481748 For each axis,
17491749 independently determine the integer multiple of its natural size
17501750 that puts it closest to the target size
17511751 and is greater than zero.
17521752
1753- Scale it to this integer-multiple-size as for ''nearest-neighbor '' ,
1753+ Scale it to this integer-multiple-size as for ''crisp-edges '' ,
17541754 then scale it the rest of the way to the target size as for ''smooth'' .
17551755
17561756 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 '' .
17581758 At non-integer multiples, this usually gives better visual results,
17591759 even for pixel art,
17601760 but it does incur a performance penalty
17611761 due to the "two-step" rendering requirement.
17621762
17631763 <dt> <dfn caniuse="css-crisp-edges">crisp-edges</dfn>
17641764 <dd>
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,
17661766 and which does not smooth colors or introduce blur to the image in the process.
17671767
1768- This <em> may</em> be identical to ''nearest-neighbor'' ,
1769- but UAs may use any algorithm that meets the requirements.
1770-
1771- <dt> <dfn>nearest-neighbor</dfn>
1772- <dd>
17731768 The image must be scaled with the "nearest neighbor" algorithm:
17741769 treating the original image's pixel grid as a literal grid of rectangles,
17751770 scale those to the desired size,
@@ -1779,56 +1774,81 @@ Determining How To Scale an Image: the 'image-rendering' property {#the-image-re
17791774 Note: If the new size is not an integer multiple of the original size,
17801775 the NN algorithm can introduce significant "aliasing" bugs;
17811776 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
17831778 depending on where they appear,
17841779 etc.
17851780 </dl>
17861781
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.
17881785 For example, with ''image-rendering: auto'' ,
17891786 a user agent might scale images with bilinear interpolation by default,
17901787 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.
17951790
17961791 <div class='example'>
17971792 For example, given the following small image:
17981793
17991794 <figure>
18001795 <img src="images/pixel-art-small.gif">
1801- <figcaption> A small pixel-art image.
1796+ <figcaption> A small pixel-art image.</figcaption>
18021797 </figure>
18031798
18041799 Scaling it up 3x might look like the following,
18051800 depending on the value of 'image-rendering' :
18061801
18071802 <figure>
18081803 <img src="images/pixel-art-small.gif" width=384>
1809- <figcaption> The image scaled with ''image-rendering/auto '' </figcaption>
1804+ <figcaption> The image scaled with ''smooth '' </figcaption>
18101805 </figure>
18111806
18121807 <figure>
18131808 <img src="images/pixel-art-nn.png">
1814- <figcaption> The image scaled with ''pixelated'' </figcaption>
1809+ <figcaption> The image scaled with ''pixelated'' or ''crisp-edges'' </figcaption>
1810+ </figure>
1811+ </div>
1812+
1813+ <div class='example'>
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+ <figure>
1821+ <img src="images/pixel-art-small.gif">
1822+ <figcaption> The same small pixel-art image as before.</figcaption>
1823+ </figure>
1824+
1825+ <figure>
1826+ <img src="images/pixel-art-small.gif" width=320>
1827+ <figcaption> The image scaled 2.5x with ''smooth'' </figcaption>
18151828 </figure>
18161829
18171830 <figure>
1818- <img src="images/pixel-art-smooth.png">
1819- <figcaption>
1820- The image scaled with ''crisp-edges'' .<br>
1821- <small> (Or it might look like ''nearest-neighbor'' ,
1822- or as another type of pixel-scaling algorithm,
1823- depending on the browser.)</small>
1824- </figcaption>
1831+ <img src="images/pixel-art-nn.png" width=320>
1832+ <figcaption> The image scaled 2.5x with ''pixelated'' </figcaption>
18251833 </figure>
1834+
1835+ <figure>
1836+ <img src="images/pixel-art-nn-2p5.png">
1837+ <figcaption> The image scaled 2.5x with ''crisp-edges'' </figcaption>
1838+ </figure>
1839+
1840+ The ''pixelated'' version maintains the overall <em> look</em> of simply scaling the pixels up,
1841+ at the cost of <em> slight</em> 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.
18261846 </div>
18271847
18281848 This property previously accepted the values ''optimizeSpeed'' and ''optimizeQuality'' .
18291849 These are now deprecated;
18301850 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,
18321852 and authors must not use them.
18331853
18341854
0 commit comments