mmcb Posted January 9, 2007 Share Posted January 9, 2007 I have 2 problems with displaying images directly to the browser:1) I have worked out how to display the image:[code]$filename='testimage.jpg';header ('Content-Type: image/jpeg'); imagejpeg($filename);[/code]No problem there, it works great, the image is displayed just as it should be. But, when I try to save the jpg image I can only save it as a BMP file!! For some reason the browser doesn't recognise that it is a jpg file. It is happening to other people as well, so it's not a local computer problem.2) My second problem is that the displayed image (when saved) is a different resolution to the original. The original image has a 300dpi resolution. Why does this change when the image is displayed in this style?? When I use a normal IMG tag to display the jpg it retains the 300dpi resolution.Any help would be greatly appreciated as this is driving me nuts ??? Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/ Share on other sites More sharing options...
mmcb Posted January 12, 2007 Author Share Posted January 12, 2007 I'll take it that no-one can help me with this then.........*sigh*MMCB Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159153 Share on other sites More sharing options...
kobmat Posted January 12, 2007 Share Posted January 12, 2007 Try$filename='testimage.jpg';header ('Content-Type: image/jpeg'); readfile($filename); Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159183 Share on other sites More sharing options...
mmcb Posted January 13, 2007 Author Share Posted January 13, 2007 I tried that already and it still doesn't work. It displays the image fine (same as imagejpeg does), but I still can't save the image as a JPG.MMCB Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159671 Share on other sites More sharing options...
kobmat Posted January 13, 2007 Share Posted January 13, 2007 try$filename='testimage.jpg';header('Content-Disposition: inline; filename="'.$filename.'"');header ('Content-Type: image/jpeg'); readfile($filename); Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159811 Share on other sites More sharing options...
mmcb Posted January 13, 2007 Author Share Posted January 13, 2007 *sigh* Nope, that didn't work either :(Could it have something to do with the server configiration or am I just clutching at straws here?Cheers,MMCB Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159883 Share on other sites More sharing options...
redbullmarky Posted January 13, 2007 Share Posted January 13, 2007 whilst it might not solve the problem, lets try getting things into the "normal" way of doing things. [url=http://uk2.php.net/imagejpeg]imagejpeg[/url] (function) takes 3 parameters - the 'resouce', a '[b]destination[/b]' filename, and a 'quality' setting.[code]<?php$im = imagecreatefromjpeg('testimage.jpg');header('Content-type: image/jpeg');imagejpeg($im);?>[/code]the default quality setting for imagejpeg is 75%. if you want higher, use (for example)[code]imagejpeg($im, '', 90);[/code]have you tried this on a different browser yourself, just to make sure that its not an issue of what the browser is set to accept? Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159886 Share on other sites More sharing options...
tarun Posted January 13, 2007 Share Posted January 13, 2007 what browser are you using if you can only save it as a bmp file Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-159895 Share on other sites More sharing options...
mmcb Posted January 13, 2007 Author Share Posted January 13, 2007 I've changed the code to:[code]$im = imagecreatefromjpeg($filename);header('Content-type: image/jpeg');imagejpeg($im,'',100);[/code]Where $filename comes from a MySQL table.I've tried it in IE6 and Firefox, both browsers display the image perfectly. However, IE only lets me save it as a BMP file. Firefox on the otherhand wants to save the php file (downloadimage.php). If I try saving it as a .jpg it won't open in graphics programs. However, atleast with firefox I have the ability to copy image which works.Am I missing something or what? I've been through all the tutorials I can find and they all seem to work.MMCB Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-160091 Share on other sites More sharing options...
Jessica Posted January 13, 2007 Share Posted January 13, 2007 How are you trying to save it? Right click and... Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-160093 Share on other sites More sharing options...
mmcb Posted January 13, 2007 Author Share Posted January 13, 2007 Yep.Right Click, save image as.......In IE I get:Filename: untitledSave As Type: Bitmap (*.BMP)In Firefox I get:Filename: downloadimage.phpSave As Type: All Files Quote Link to comment https://forums.phpfreaks.com/topic/33459-image-displaysave-as-problem/#findComment-160097 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.