Questions tagged [png]

PNG (Portable Network Graphics) is an image file format designed to store raster graphics. It is associated with ".png" file extension. Use this tag for questions involving this specific format.

PNG was created to improve upon and replace (Graphics Interchange Format) as a losslessly compressed image file format not requiring a patent license.

PNG supports palette-based images with transparency, true colour images with or without alpha channel (RGB, RGBA), and grayscale images; PNG supports channel depths from 1-bit to 16-bit per channel. Interlacing, which allows the progressive display of partially downloaded images, is implemented via the Adam7 algorithm. Animation is supported by way of the extension.

More information

6735 questions
814
votes
16 answers

Capture HTML canvas as GIF/JPG/PNG/PDF?

Is it possible to capture or print what's displayed in an HTML canvas as an image or PDF? I'd like to generate an image via canvas and be able to generate a PNG from that image.
Parand
  • 102,950
  • 48
  • 151
  • 186
700
votes
29 answers

Change color of PNG image via CSS?

Given a transparent PNG displaying a simple shape in white, is it possible to somehow change the color of this through CSS? Some kind of overlay or what not?
user429620
602
votes
14 answers

What are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?

When should certain image file types be used when building websites or interfaces, etc? What are their points of strength and weakness? I know that PNG & GIF are lossless, while JPEG is lossy. But what is the main difference between PNG & GIF? Why…
Faruz
  • 9,909
  • 10
  • 48
  • 66
578
votes
20 answers

How to convert a SVG to a PNG with ImageMagick?

I have a SVG file that has a defined size of 16x16. When I use ImageMagick's convert program to convert it into a PNG, then I get a 16x16 pixel PNG which is way too small: convert test.svg test.png I need to specify the pixel size of the output…
kayahr
  • 20,913
  • 29
  • 99
  • 147
519
votes
9 answers

favicon.png vs favicon.ico - why should I use PNG instead of ICO?

Other than the fact that PNG is a more common image format, is there any technical reason to favor favicon.png vs. favicon.ico? I'm supporting modern browsers which all support PNG favorite icons.
Jon Galloway
  • 52,327
  • 25
  • 125
  • 193
395
votes
17 answers

Replace transparency in PNG image with white background

I have a PNG image with an alpha channel (i.e. transparency), and I need to create versions with the image layer composed onto a white background. I want to use a scriptable command using a CLI tool such as Image Magick to directly convert PNG to…
Pointy
  • 405,095
  • 59
  • 585
  • 614
293
votes
15 answers

Drop shadow for PNG image in CSS

I have a PNG image, that has free form (non square). I need to apply drop-shadow effect to this image. The standard approach ... -o-box-shadow: 12px 12px 29px #555; -icab-box-shadow: 12px 12px 29px #555; -khtml-box-shadow: 12px 12px 29px…
AntonAL
  • 16,692
  • 21
  • 80
  • 114
285
votes
3 answers

Favicon: .ico or .png / correct tags?

In a HTML5 document, which favicon format do you recommend and why? I want it to be supported by IE7 and all the modern browsers. Also, when using .png, do I need to specify the type (type="image/png")?
Richard
  • 3,839
  • 5
  • 28
  • 34
266
votes
15 answers

How to convert a PNG image to a SVG?

How to convert a PNG image to a SVG?
user199337
  • 8,063
  • 7
  • 23
  • 18
227
votes
11 answers

Android splash screen image sizes to fit all devices

I have a full screen PNG I want to display on splash. Only one error there, and I have no idea what size to put in every drawable folder (ldpi, mdpi, hdpi, and xhdpi). My application is supposed to run good and beautiful on all phones and tablets.…
rel-s
  • 6,108
  • 11
  • 38
  • 50
184
votes
3 answers

Favicon Standard - 2023 - svg, ico, png and dimensions?

What favicon dimensions, file formats and meta/link tags should be used as of 2022? This includes apple icon, windows, android and other devices people use today. I use Opera and I can see it supports svg format. Is it the best solution to use svg…
Jakub Muda
  • 6,008
  • 10
  • 37
  • 56
169
votes
10 answers

Convert UIImage to NSData and convert back to UIImage in Swift?

I'm trying to save a UIImage to NSData and then read the NSData back to a new UIImage in Swift. To convert the UIImage to NSData I'm using the following code: let imageData: NSData = UIImagePNGRepresentation(myImage) How do I convert imageData…
pete
  • 2,980
  • 4
  • 22
  • 34
163
votes
8 answers

Set transparent background using ImageMagick and commandline prompt

Suppose you have any image (PNG or JPG). This image has a white background and I need to make this background transparent. I have tried with these examples: convert original.png -background none transparent.png convert original.png -background…
Israel
  • 3,252
  • 4
  • 36
  • 54
147
votes
8 answers

Convert RGBA PNG to RGB with PIL

I'm using PIL to convert a transparent PNG image uploaded with Django to a JPG file. The output looks broken. Source file Code Image.open(object.logo.path).save('/tmp/output.jpg',…
Danilo Bargen
  • 18,626
  • 15
  • 91
  • 127
125
votes
6 answers

Does PNG contain EXIF data like JPG?

I was wondering if PNG contains data like the following? What I did was to convert the jpg file to png format, and I was expecting to retrieve the same info I had on the jpg as below: Currently using this as3 library to read the data. IDF0--- IDF…
user1004413
  • 2,509
  • 6
  • 23
  • 33
1
2 3
99 100