| Bug : | Resize avatar/photo/signature if larger than limit |
| Status : | Fixed |
| Severity : | Enhancement |
| Reporter : | Spartan |
| Updated by : | Olivier C. |
| Category | Users |
| Version : | 121 |
| Frequency : | Consistently |
| Fixed in : | 125 |
| Details : | This is the code I used on my old LDU modified site that simulated Facebook in everyway.. Code: if ($w>=$cfg['ph_maxx']) { $photo = $usr['id']."-photo.gif"; $photopath = $cfg['photos_dir'].$photo; if (file_exists($photopath)) { unlink($photopath); } move_uploaded_file($uph_tmp_name, $photopath); $tmpimg = tempnam("/tmp", "MKUP"); system("djpeg $photopath >$tmpimg"); system("pnmscale -x $cfg['ph_maxx'] $tmpimg | cjpeg -smoo 10 -qual 100 >$photopath"); unlink($tmpimg); $uph_size = filesize($photopath); $sql = ldu_query("UPDATE $db_users SET user_avoto='$avotopath' WHERE user_id='".$usr['id']."'"); $sql = ldu_query("DELETE FROM $db_pfs WHERE pfs_file='$avoto'"); $sql = ldu_query("INSERT INTO $db_pfs (pfs_userid, pfs_file, pfs_extension, pfs_folderid, pfs_desc, pfs_size, pfs_count) VALUES ('".$usr['id']."', '$avoto', '$f_extension', '-1', '', '$uao_size', '0')"); @chmod($avotopath, 0666); } Basically what it does is resize images instead of not uploading at all. For example: If the maximum width of a photo was set to 100, then.. Image before resize - 150x210 Image after resize - 100-140 The nice thing about the above script is that it maintains very high quality of the original image without making the file size larger than it already is. |
| Items affected : |
History and comments :
| 18-11-2007 20:40 Trustmaster Here is a better solution using ImageMagick and fixing another Seditio bug. Though, I couldnt avoid using system(). |
| 16-07-2007 11:11 Olivier C. PM sent to the reporter : |
| 16-07-2007 11:10 Olivier C. Done, 3 new hooks : |
| 16-07-2007 11:08 Olivier C. Hardly, it's platform dependent because of the system calls. |
| 18-06-2007 05:51 the.dave sound like a really good idea, maybe user can even selectionate their picture throught the pfs system ! |
| 13-05-2007 18:24 sbardy Take care about trasparent and animated gif. gj |
| 12-04-2007 11:13 smileytm Wow. I would also like to see this in the pfs. In ldu i already made a function like this in the pfs. The problem was that it only rezised one photo a time. |
| 08-04-2007 17:59 jslowik Oh excellent idea. I really hope this makes it into the next version! |