
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Maintain Image Quality When Applying CSS Transform & Scale
The CSS image-rendering property helps us set an algorithm for scaling our image.
Syntax
The syntax of CSS image-rendering property is as follows −
Selector { image-rendering: /*value*/ }
Example
The following examples illustrate CSS image-rendering property.
<!DOCTYPE html> <html> <head> <style> img { height: 200px; width: 200px; } #one { image-rendering: smooth } #two { image-rendering: pixelated } #three { image-rendering: crisp-edges } </style> </head> <body> <img id="one" src="https://images.unsplash.com/photo-1610208309350-766d71494a03?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=128&ixlib=rb-1.2.1&q=80&w=128" /> <img id="two" src="https://images.unsplash.com/photo-1610208309350-766d71494a03?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=128&ixlib=rb-1.2.1&q=80&w=128" /> <img id="three" src="https://images.unsplash.com/photo-1610208309350-766d71494a03?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=128&ixlib=rb-1.2.1&q=80&w=128" /> </body> </html>
This gives the following output
Example
<!DOCTYPE html> <html> <head> <style> img { padding: 5%; border-radius: 40%; height: 20%; width: 20%; } #one { image-rendering: pixelated } #two { image-rendering: smooth } #three { image-rendering: crisp-edges } </style> </head> <body> <img id="one" src="https://images.unsplash.com/photo-1611090093783-a629a4d9f1a1?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256" /> <img id="two" src="https://images.unsplash.com/photo-1611090093783-a629a4d9f1a1?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256" /> <img id="three" src="https://images.unsplash.com/photo-1611090093783-a629a4d9f1a1?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=256&ixlib=rb-1.2.1&q=80&w=256" /> <br/> pixelated, smooth, crisp </body> </html>
This gives the following output
- Related Articles
- How to scale down an image with CSS to make it responsive
- Applying Hue Rotation on Image using CSS3
- The CSS scale() Function
- FabricJS – Applying scale multiplier to a Polygon converted to a HTMLCanvasElement
- How do you improve Matplotlib image quality?
- Applying MinFilter on an image using Pillow library
- Applying MaxFilter on an image using Pillow library
- Applying ModeFilter on an image using Pillow library
- Applying MedianFilter on an image using Pillow library
- 2D Transform Functions in CSS
- A scale transform the element by using y-axis with CSS3
- A scale transform the element by using x-axis with CSS3
- A scale transform the element by using z-axis with CSS3
- OpenCV Java example to scale an image.
- How to transform background image using CSS3

Advertisements