cristianogois / timthumb

Automatically exported from code.google.com/p/timthumb
1 stars 1 forks source link

Problem with jpg files #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I'm using the latest timthumb library (v.1.14, r81)
2. GD library is added and all types PNG, JPG, GIF are enabled, GD version is 
2.0.34 taken from the latest php 5.2.14
3. I visit url like 
http://mysite.com/timthumb.php?src=http://sheilamacd.files.wordpress.com/2007/05
/kiosk-with-daft-lads.jpg&w=200&h200

The image is processed but the result is of very poor quality.
As I have everything on local server - I uploaded how the image after 
processing looks like.

What is the expected output? What do you see instead?

I have uploaded what I get as a result.
image before: 
http://sheilamacd.files.wordpress.com/2007/05/kiosk-with-daft-lads.jpg
image after: 
http://habreffect.ru/files/d85/3c865bafa/cd60e66fc274b8dcc8ebe28e0486e508.jpg

This problem occurs with JPG files only, with PNG and GIF everything is fine. 
When processing JPG - no errors or warnings in the logs appear.

What version of the product are you using? On what operating system?

I'm using timthumb v.1.14, r81 on Windows, Apache 2.2, php 5.2.14,
GD Support  enabled
GD Version  bundled (2.0.34 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.1.9
T1Lib Support   enabled
GIF Read Support    enabled
GIF Create Support  enabled
JPG Support enabled
PNG Support enabled
WBMP Support    enabled
XBM Support enabled

Please provide any additional information below.

I think that the problem is probably not in the code of timthumb, but in the GD 
library. But I ask for any advice, as I have tried everything I could to fix 
it, but without success.

PS
the JPG files are generated fine when I'm using standard image processing 
library in Codeigniter (this is the framework I use). So it looks like that  
the same GD library provides proper results.

Original issue reported on code.google.com by beauty.r...@gmail.com on 6 Aug 2010 at 7:17

GoogleCodeExporter commented 9 years ago
are you passing a q parameter at all? It looks like the quality is set to the 
lowest possible. If not using q then try adding q=90 to your timthumb url

Original comment by BinaryMoon on 10 Aug 2010 at 3:22

GoogleCodeExporter commented 9 years ago
I was trying to put quality parameter, even q=100 - it is not solving the 
problem.

I have seen that all cache files are created as PNG, even when the original 
source is JPG.

So I was trying different fixes and I found what has helped me:

in the function show_image() I have changed

        case 'image/jpeg':
            imagejpeg($image_resized, $cache_file_name, $quality);
            break;

to

        case 'image/jpeg':
            imagepng($image_resized, $cache_file_name, $quality);
            break;

and it started working as expected, I'm not yet totally understand why it is 
working now and was not working before, I will try to find it out later, at 
least I got it working.

If you have any thoughs - I would glad if you could help.
tnx

Original comment by beauty.r...@gmail.com on 10 Aug 2010 at 6:35

GoogleCodeExporter commented 9 years ago
Hi - I think this is now fixed.

Original comment by BinaryMoon on 29 Aug 2010 at 9:57

GoogleCodeExporter commented 9 years ago
I have tested the lates r85 release.

The problem is still there.

I see you have changed switch() to if else with stristr.

Actually, mime-type is 'image/jpeg' and in both cases (now and before) the 
first condition is met and the following is run:
   imagejpeg ($image_resized, $cache_file, $quality);

but this imagejpeg is causing the erroneus image.

I have tested it locally and my hoster server - the behavior is the same. The 
versions of Apache and GD library are the same.

Which version of GD library do you use?

Original comment by beauty.r...@gmail.com on 30 Aug 2010 at 6:39