I have designed an arrow shape image(100px*25px) in Photoshop. I am using that image in HTML label background. I have written CSS to change image width dynamically.but its sharpness changing when label width reduces.so how I can maintain the original quality as per width changes.
-
Hi user3148335, I would suggest asking this question to stackoverflow.com as this deals with coding. When asking this type of question, it is best to include the CSS you're using for the image. You could put all of the code into a jsfiddle.net– AndrewHCommented May 5, 2015 at 16:25
-
i tried svg format also,but when i reduce image width then sharpness decreasing.so what should i do to maintain the image. quality .– user3148335Commented May 9, 2015 at 14:19
2 Answers
If the image is raster (JPG, PNG or GIF) then there is nothing you can do. If you specify dimensions in the CSS different from the actual dimensions of the image source, then the browser will need to do some re-sampling be able to render the image at the requested dimensions. The reason for this is that the browsers need to make up missing pixels if you specify larger dimensions or condense the pixels if you specify smaller dimensions. Different browsers and devices are bound to have different re-sampling algorithms, so you are bound to have a myriad of different user experiences.
If the image is vector (SVG), though, then you will always have a sharp-ish result. The reason for the "ish" is that, depending on the dimensions and the art, the browser might need to do some anti-aliasing in order to render fractional pixel shapes.
-
-
@user3148335: Take a look at this link. It might help: creativedroplets.com/generate-svg-with-photoshop-cc-beta– cockypupCommented May 6, 2015 at 15:50
-
i tried svg format also,but when i reduce image width then sharpness decreasing.so what should i do to maintain the image. quality . Commented May 8, 2015 at 5:05
Rescaling a rasterized image is usually not the best way to go in this situation. I would consider taking your shape into illustrator and saving it as an SVG, which you can then use .
Alternatively, if you are hell-bent on keeping your rasterized arrow, you could experiment with the image rendering css property.
Try this in your css
.your-image-class {
image-rendering: crisp-edges;
}
From: https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
-
2Just a small comment, please notice that this property is only partially supported: caniuse.com/#feat=css-crisp-edges– cockypupCommented May 5, 2015 at 16:35
-
i tried svg format also,but when i reduce image width then sharpness decreasing.so what should i do to maintain the image. quality . Commented May 9, 2015 at 14:18