Suggestion as regards to the mistake after uploaded avatar from disk

Started by jsx, November 14, 2012, 03:40:27 AM

Previous topic - Next topic

jsx

Hi, I would like to report this mistake which I described here: http://www.simplemachines.org/community/index.php?topic=489905.msg3432945#msg3432945 the problem is so, that if after adding the inscription on avatar in the jpg format this avatar uploading through uploaded it from the disk the problem is so the inscription is losing the quality. The problem isn't appearing if avatar is adding from link or in png format.

I would ask the SMF team at one time you enter some corrections in order to eliminate this mistake.

I'll write one more time, this problem isn't appearing in SMF 1.1.16 I used this version long time and I never noticed this problem.

Antechinus

Why can't you use .png? Jpg is a lossy format. If you create a jpg and then resize it, you are going to get extra losses. That's just the way it works. If you don't want a lossy format, use png.

mrintech

Quote from: Antechinus on November 14, 2012, 05:30:39 AM
Why can't you use .png? Jpg is a lossy format. If you create a jpg and then resize it, you are going to get extra losses. That's just the way it works. If you don't want a lossy format, use png.

I agree completely

http://en.wikipedia.org/wiki/Lossy_compression

Try using PNG or GIF instead :)

Antechinus

Png is better than gif. Unless you want animation, there's no point using gif.

jsx

@Antechinus I have always used jpg to avatars. For the first time I met with something like that. But I understand.

Akyhne

It is actually a "bug" in SMF.

The SMF software has always been using the GD function imagejpeg() with no parameter on the compression. This means that images are compressed to the standard 75% compression.
As JPEG images are already compressed, this means even more loss to the quality. You can increase the quality, by editing the Subs-Graphics.php file:
$success = imagejpeg($dst_img, $destName);

Change to
$success = imagejpeg($dst_img, $destName, 82);

82% quality is the setting I've always found to be the edge where you can hardly see any compression. More than that, makes no sense. This is due to the way imagejpeg() works. Unfortunately, 100% quality doesn't mean the image isn't compressed further. It's hardly compressed further with a pro editor on the computer, but the function in GD doesn't seem to understand this.

imagejpeg() has another bad habbit, which shows a lot with your image. It doesn't like red colors!
Another issue is that you are uploading a 110*110 image to 110*110 size. If the original image is larger, say twice as big (least), the image will not look so ugly. That is because in a 1:1 size conversion with compression, the image gets more and more compressed.
Try uploading the image, save it, upload it again like 10 times. The image will be more and more compressed, even when quality is set to 100%.

When all this is said, you still get a lot nicer quality by editing the imagejpeg() function.

SMF should have a quality factor setting for JPEG's. Most other software has.

jsx

I understand and I hope that the people from SMF someday will improve this function to uploaded avatar will be good shown in jpg. Thanks for information.

Arantor

2.1 defaults compression to 82 rather than 75 for all supported JPEG converters (GD, Imagick, MagickWand) and there is a hidden option which may - if desired - get a UI later. But for now this is solved.

As for why it hates red, that's a by-product of the way JPEG handles colours; it doesn't store RGBs, but breaks images down usually into YCbCr (luminescence, followed by blue- then red-difference chroma components). You probably don't need to understand why this is the case but if you're bored, the Wikipedia articles on JPEG itself and more specifically about YCbCr are interesting reading. (Basically, if you store standard RGB components, you will have less redundancy that you can safely drop, but when dealing with luminescence as a major factor, you can generate a higher ratio of safely-droppable redundant data)
Holder of controversial views, all of which my own.


Advertisement: