| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 108742 | 2010-04-09 21:42:00 | Jpeg finding the image quality in PHP | Morgenmuffel (187) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 874677 | 2010-04-09 21:42:00 | Hi all I have been having an issue with php and image resizing/resampling, Basically i have an upload function that resizes and resamples jpegs and it works fine, however there is one small issue, What i want to do, is to only reduce the jpeg quality on all images that have a jpeg quality of above 80%, any jpegs that have a quality of lower than 80% should be ignored by the resample function. However i can't figure out how to detect the jpeg quality, so currently all images are resampled which results in some images becoming larger than the initial image So basically - How do i detect jpeg quality in PHP Thanks |
Morgenmuffel (187) | ||
| 874678 | 2010-04-09 22:32:00 | AFAIK there is no "quality" for an existing jpeg, it is only a parameter passed to the compression algorithm that tells it how much data to chuck out. Unless the compressor writes it in the EXIF header, but I haven't seen that. Maybe you could compare the filesize with the resolution and make a call based on that? |
fred_fish (15241) | ||
| 874679 | 2010-04-10 01:00:00 | ^ What he said - it's a parameter passed to the encoder, it's not something you can fish out of an existing image. | Erayd (23) | ||
| 874680 | 2010-04-10 03:47:00 | Then how do programs like fireworks etc know what level of compression an image has, when i open an existing image? I am not doubting you guys, i just don't understand, does fireworks estimate it? |
Morgenmuffel (187) | ||
| 874681 | 2010-04-10 04:13:00 | Then how do programs like fireworks etc know what level of compression an image has, when i open an existing image?I'm guessing so. However... if you have images that Fireworks is correctly figuring out the compression quality for, try taking a look at the EXIF data attached to the image - it may be that whatever compressed it has left a note in there. | Erayd (23) | ||
| 874682 | 2010-04-10 06:37:00 | I don't suppose there is away to guess in php Alternatively I could just resample all images, then compare the size of input image against the output image and keep the smaller one |
Morgenmuffel (187) | ||
| 874683 | 2010-04-10 11:07:00 | I don't suppose there is away to guess in php... Well as fred_fish suggested, why don't you compare the resolution with the filesize? That'd certainly give you a decent starting point for a guess. |
Erayd (23) | ||
| 874684 | 2010-04-10 12:09:00 | No worries, I just have a person who regularly puts up 1mb images and then sets them to display at thumbnail size in their pages, and can't understand why their pages are slow and the server space is shrinking, thought I would idiot proof the upload part of FCKeditor | Morgenmuffel (187) | ||
| 874685 | 2010-04-10 12:50:00 | Aaah, one of *those* users. Smart thinking :thumbs:. | Erayd (23) | ||
| 1 | |||||