1

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.

2
  • 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
    – AndrewH
    Commented 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 . Commented May 9, 2015 at 14:19

2 Answers 2

1

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.

3
  • How I can convert into svg format in Photoshop. Commented May 6, 2015 at 15:37
  • @user3148335: Take a look at this link. It might help: creativedroplets.com/generate-svg-with-photoshop-cc-beta
    – cockypup
    Commented 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
0

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

2
  • 2
    Just a small comment, please notice that this property is only partially supported: caniuse.com/#feat=css-crisp-edges
    – cockypup
    Commented 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.