I am using popular timthumb.php to resize images. i am successfully able to change height and width of image but whenever i do "save as" by default it saves as php..
for example, if you try to save the image present at http://www.binarymoon.co.uk/demo/timthumb-basic/timthumb.php?src=castle1.jpg&w=400 it saves as a file with extension php..
how do i force to save it as png/jpg? i know the mime type is image/jpg or image/png .... all i want is the image should save as png or jpg by default... kindly help
Timthumb doesn't have "save as" option (see this reply http://o7.no/biJTYD on the developer blog http://www.binarymoon.co.uk/2010/11/timthumb-hints-tips/). Timthumbs saves the processed image with the same format as the source image.
I succeded in forcing a "save as jpg" when source is "png" with the followingwork around (near line 742). You may arrange other conversions working on the if-then-else chain.
if(preg_match('/^image\/(?:jpg|jpeg)$/i', $mimeType)){
$imgType = 'jpg';
imagejpeg($canvas, $tempfile, $quality);
} else if(preg_match('/^image\/png$/i', $mimeType)){
// ***************WORKAROUND STARTS HERE****************
//$imgType = 'png';
//imagepng($canvas, $tempfile, floor($quality * 0.09));
$imgType = 'jpg';
imagejpeg($canvas, $tempfile, $quality);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With