JPG is a lossy compression algorithm while PNG is a lossless one .
Up vote 6 down vote favorite share g+ share fb share tw.
I'm using ImageMagick to convert some files from one format to another. I was always under the impression that . Png files were supposed to be as big/small as .
Jpg if not smaller, and definitely smaller than .gif. However when I run convert photo. Jpg photo.
Png The files I'm getting out is about 6 times bigger than the original jpg. Original jpg is a regular photo about 300x500 px, 52 kb. Output is a proper png of the same dimensions, but size is about 307 kb?
Does anyoone know what the hack is going on? Am I doing something wrong? P.S.: I tried both on Debian and Windows with the same results.
P.P.S.: Also when I add resize option to this and resize to 10000 x 10000. Converting and resizing to jpg takes a few seconds, but it works, if I do the same of png, I jsut strt running out of memory altogether image-processing png imagemagick jpg gif link|improve this question asked Apr 21 '10 at 21:31Nick Gorbikoff1,714525 98% accept rate.
JPG is a lossy compression algorithm while PNG is a lossless one. This fact alone will (in general) make JPG images smaller than PNG ones. You can tweak the compression ratios for each format, so it could also be that your not compressing your PNG files as much as your JPG ones.
For a photographic image saving as JPG will usually produce a smaller file than PNG as there's more noise or randomness in the image for the compression to work with. Images created by graphic art tools will tend to have more hard edges which will compress better in PNG. GIF is smaller because it's based on an colour palette (of 256 colours) rather than the separate RGB values for each pixel (or group of pixels) in JPG and PNG.
Chris, thanks for a speedy reply. I haven't done programmatic images processing before, and coming from gui products such as Photoshop and Paintshop, I'm used to having smaller pngs, since they use optimized pallets by default. Is there any way to get imagemagick to reduce quality in order to do conversion to png faster?
– Nick Gorbikoff Apr 21 '10 at 21:41 @Nick - I don't know imagemagick so I can't say for sure, but there should be an "options" button somewhere, either on the save dialog itself or in the preferences. – ChrisF Apr 21 '10 at 21:43 No idea about imagemagick but any good image editor should have a function which reduces the number of colors used in the picture. – Bus Apr 21 '10 at 21:45 ImageMagick is a command line processing tool, so not button :-( Trying to read through docs right now but it's a pain.
– Nick Gorbikoff Apr 21 '10 at 21:45 @Nick - told you I didn't know imagemagick ;) – ChrisF Apr 21 '10 at 21:47.
The PNG format can provide images of 24 bits per pixel or 8 bits per pixel. JPG is a 24 bit format, but it uses lossy compression to reduce the file size significantly. PNG and GIF both use lossless compression, but GIF only works with 8 bits so it requires your image to have 256 colors or less - this often results in a grainier picture.
Try the -colors and -dither options in ImageMagick to reduce the number of bits in your PNG output. At that point it should be comparable to the GIF file size. If you need to reduce it further, there are utilities to optimize the PNG.
Mark thank you for advice, but even -colors 254 for png, produces and image bigger than jpeg. I guess I'll have to save everything as jpgs. Thank – Nick Gorbikoff Apr 21 '10 at 22:22 @Nick, one question - are your gifs also larger than the jpgs?
If so, you've probably made the right choice. Png might be smaller than gif, but not by a huge margin. – Mark Ransom Apr 21 '10 at 22:52 yeah gifs are definitely larger - no surprise there, I just always thought that png would produce better results.
But since I really don't strive for quality here, but rather for smaller size, jpg it is. Thank you – Nick Gorbikoff Apr 21 '10 at 23:25.
The . Jpeg file format is a lossy format, it throws information away. Which makes for good compression ratios.
The . Gif file format is not lossy but loses other information, it only supports 256 colors. The .
Png file format is not lossy and preserves the color range.
The key thing to note here is that each image file format is best for specific purposes. JPEG stands for “Joint Photographic Experts Group. ” That right there should tell you that the .
JPG file format is optimized for photographs. It doesn’t work so well for line-art, logos, gradient or tiled / patterned backgrounds, and the like. .
JPG’s DCT (Discreet Cosine Transform) artifacts (the “blocky” artifacts we all know and loathe) are much more noticeable with line art and logos than with photos. PNG has replaced GIF for everything that GIF was ever good for, except one, and that only because no clear standard has emerged: animations. Animated .
GIFs are well known on the Web. There are two competing standards for animated . PNGs: APNG and MNG.
APNG is supported in most modern browsers, and is also fully backwards compatible (the file extension is . PNG, not . APNG, and if any program that can display .
PNGs but doesn’t know APNG is “fed” an APNG, it will display either a stand-in image of the developer’s choice, or the first frame of the animation if no such stand-in was provided — as far as the older program is concerned, it’s just an ordinary single-frame . PNG with that one image in it — the rest is safely ignored). Gekko (FF, etc.) and Presto (Opera) support it natively, and Google Chrome (using Webkit) can with an add-on.
MNG has the backing of the actual PNG-format development team, but is its own format and is not backwards compatible, but is more powerful and flexible. Right now, only KHTML-based browsers (Konquerer) support it: not Trident (IE), Gekko, Webkit (Chrome, Chromium, Safari), nor Presto. PNG does everything (except animations unless enhanced with APNG) that GIF does, and better.
All else being equal, a . PNG will almost always be smaller than a . GIF at the same resolution and bit depth.
Like . GIF, . PNG can support color depths up to 8 bits per pixel in indexed-color (paletted) mode, but unlike .
GIF (yet like . JPEG) it also supports direct-color mode at 24 bits per pixel. In either mode it can add 8 bits of alpha transparency, unlike .
GIF (which can only do indexed color transparency pick a color out of the palette to be replaced with 100% transparency, aka invisibility — . PNG can do that, too). Alpha transparency produces much better results than indexed transparency, because the pixels can be partially transparent, whereas with indexed transparency (the only kind available in .
GIF) your choices are either opaque or invisible. This makes for “halos” around non-rectangular objects when placed against background colors other than the one the . GIF or indexed .
PNG was originally “matted” against. It also inhibits being able to do effects such as glows, drop shadows, and, of course, see-through colored objects (without dithering). Alpha transparency can do all of those things with ease, against almost any background (glows would be largely invisible on a white background, and drop shadows would be invisible on black, but you know what I mean).
Yes, you can do 8-bit alpha transparency in an indexed-color . PNG! And guess what?
Even Windows Internet Explorer 6 can display those just fine, complete with transparency! It’s only the 32-bit . PNGs (24-bit RGB color + 8-bit alpha) that IE6 choked on and displayed as gray!
The most well-known program that can export PNG8 (indexed color) with alpha transparency is Adobe (formerly Macromedia) Fireworks. The Photoshop “Save for Web and Devices” (at least as of CS3) could not do that, despite having basically lifted the feature from Fireworks when Adobe bought out Macromedia. It can save PNG8, but only with indexed-color transparency.
Anyway, full 32-bit (or even 24-bit) PNGs will be pretty large, though usually much smaller than the nearest equivalent . BMP or . TGA or uncompressed .
TIFF or some such (unless you’re trying to do a photograph with it — that’s what JPEG is for! ). It will usually be somewhat smaller even than .
RLE (losslessly compressed . BMP) or losslessly compressed . TIF, all else being equal.
Unlike most of these other formats, PNG also supports 48-bit RGB color, with optional 16 bits of alpha transparency, for extremely high quality (much higher than most monitors can display). These are best used as an intermediate storage format, to retain information from a high bit depth scanner or camera (RAW mode) or some such. Their file sizes would be quite large, despite the lossless compression.
One thing that . PNG cannot currently do is handle non-RGB color spaces such as CMYK or L*a*b. In short: For photographs, use .JPG.
For line art and logos of limited color, use indexed-color . PNG (PNG8), with alpha transparency if needed. For line art and logos of extensive color (e.g. Lots of gradient fills, metallic chrome-type reflection effects, etc.), use direct-color .
PNG (PNG24) with alpha if needed, if you want the best quality or need transparency (and don’t mind it not working in IE6 or use one of a variety of IE6 workarounds for transparent PNGs), and don’t mind the larger files and bandwidth usage. Otherwise, use . JPG, but be aware that the quality will be degraded.
You may need to crank the JPEG quality up pretty high, especially for logos or other graphics with “text” in them, which would reduce your file size savings. For non-Flash/Silverlight/video/HTML5 Canvas animations, . GIF if the main choice at present, but be prepared to switch to APNG (I don’t think MNG is going to beat it, despite the more official support from the JPEG developers).
Admit it, you did. Excellent, +1. – Tom Anderson Mar 13 at 23:27 Great informative article that complete missed the question - which was about converting from jpg to png using ImageMagick, not about merits of one format or another, which I'm quiet familiar with.
Perhaps this answer should be classified as a community wiki? – Nick Gorbikoff Mar 14 at 16:41 Thanks, Tom. But no, I already had the account.
– Joel of MMCC 16 hours ago Nick, that may’ve been what you intended, but it was not what you actually asked. What you asked was why the . PNG output from ImageMagick was so much bigger than the .
JPG output, all else being equal, and the answer is simply that ImageMagick itself is irrelevant here. . PNG24 is itself inherently much bigger than .
JPG, all else being equal for photo-type images, because for such images, lossless compression (which . PNG does) will almost always produce much bigger images than lossy compression (which . JPG does).
The program that produces them is largely irrelevant. – Joel of MMCC 16 hours ago.
It depends on the kind of image. JPEG's lossy compression works very well on images with lots of color gradients (i.e. Photos).
Try it on an image consisting of areas with the same color separated by sharp edges (screenshots are good, unless they show a photo desktop background, and the fancy window borders and task bar of Vista and Windows 7 also tend to mess this up). JPEG is bad at that kind of thing, and you'll probably find PNG to compress better (probably better than GIF too).
The PNG format can provide images of 24 bits per pixel or 8 bits per pixel. JPG is a 24 bit format, but it uses lossy compression to reduce the file size significantly. PNG and GIF both use lossless compression, but GIF only works with 8 bits so it requires your image to have 256 colors or less - this often results in a grainier picture.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.