Re: How to improve image resolution
by BrowserUk (Patriarch) on Aug 06, 2005 at 05:42 UTC
|
How are you generating your images? What format are you writing your images to disk in? What compression level (if any) are you specifying when writing them?
What, if anything, you can do to improve the appearance of your images depends very much on what you are already doing.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] |
|
|
Thanks for the posting. Sorry for not including these details before.
I am basically creating an image using the image() and printing it in gif format. The images does nothave smooth margins and also the colors donot appear as true color. I am not aware of any compression.
Thanks
$im = new GD::Image(1000,100);
blah...blah
print $im->gif;
| [reply] [d/l] |
|
|
$im = new GD::Image(1000,100, 1); ## Note the extra parameter!
From the GD docs:
The optional third argument, $truecolor, tells new() to create a truecolor GD::Image object. Truecolor images have 24 bits of color data (eight bits each in the red, green and blue channels respectively), allowing for precise photograph-quality color usage. If not specified, the image will use an 8-bit palette for compatibility with older versions of libgd.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [d/l] |
|
|
|
|
|
Re: How to improve image resolution
by neniro (Priest) on Aug 06, 2005 at 07:46 UTC
|
Remember that the .gif-format only allows a 256 color-palette, so it's ugly to save 24-bit images in it (extremly with a fixed palette). Try .png24 or .tif, these formats use a non-lossy compression - so the results should be much better. | [reply] |
|
|
You can save a 24 bit image as a GIF without any loss of quality, provided that your 24 bit image only uses 254 colors other than black or white, and the program doing the conversion supports adaptive palettes, rather than using the 'web' palette, or the system palette.
The problem with GIF is if there are too many colors, or the colors aren't defined in the color palette, the graphics program must either select the 'closest' color (for which every program handles this differently -- some just use the closest in terms of an RGB color cube, while others have algorythms to deal with a typical human's ability to differentiate color), or it must 'dither' the image, which involves lots of little dots of different color to make it look like the color from a distance, like the impressionist styles of Monet or van Gogh painting.
An overly restrictive color palette actually hurts the compression of GIF images, as it tracks horizontal bands of the same color -- so dithering breaks up continuous bands of color.
Because of this, GIF does well with computer generated graphics, with solid colors, no gradients, and little or none anti-aliasing. It does not handle photo realistic images, which JPEG is better for. (and yet -- JPEG has the exact opposite problem -- it doesn't handle solid colors well, especially if there are sharp changes between colors)
GIF's only loss comes from the palette selection -- the compression is LZW, the same as used in TIFF.
So, what's the point of all this? Well, it's that every image format has their own advantages -- TIFF is a great format for interchange between graphics programs, but it's not good for compatability on webpages. You just have to be aware of the advantages/disadvantages of each format, and select what works best in a particular situation.
Update: as BrowserUK pointed out, I didn't complain about PNG. There's a few different versions, and varying support for them. There's good support for PNG in web browsers, but you still may have to deal with the occassional older browser depending on your audience. (but it does hold the advantage in that field as it's a w3c recommendation). It also holds the advantage of being designed after the others, so it built on the strengths of each one, and mitigated the problems. The only thing that I'd say gives it a significant disadvantage over any other format is its non-lossy compression -- as such, a JPEG tends to be smaller for photo-realistic images (specifically because it trashed some of the data) I'd say the problems with PNG tend to be more with improperly using it, than the format on its own.
| [reply] |
|
|
| [reply] |
|
|
| [reply] |
Re: How to improve image resolution
by ChemBoy (Priest) on Aug 06, 2005 at 05:53 UTC
|
A slightly more narrow approach to BrowserUk's questions above: are you saving anything as a JPEG? If so, you almost certainly shouldn't be—GD is a terrific tool for 8-bit graphic manipulation, but 8-bit JPEGs are not generally especially pleasant to look upon, and things that should be 8-bit GIFs or PNGs, when saved as JPEG, look fuzzy and are larger than the GIF or PNG would be.
If God had meant us to fly, he would *never* have given us the railroads. --Michael Flanders
| [reply] |
|
|
Thanks for the posting. I am using gif format to create the image
| [reply] |
Re: How to improve image resolution
by bradcathey (Prior) on Aug 06, 2005 at 12:06 UTC
|
As a designer I am pretty particular about my images, and I have never been happy with the optimization and resulting quality of GD images, gif or jpg. There is no comparison between those images I optimize in Photoshop and those produced by GD.
Maximizing the color settings helps, but does not seem to have an effect on the overall resolution or quality of the image. It seems there must be other mitigating factors in how its "engine" does the work.
I have never tried Image::Magick, but I get the impression from what I have read that it is better. I have also gotten the feeling that Implementing it is difficult it, but I have no experience.
Anyway, you're not alone. My 2¢.
—Brad "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
| [reply] |