joshluv33 Posted July 28, 2008 Share Posted July 28, 2008 I've got a photography website that sells prints of images to clients. I am attempting to implement the imagefilter to produce black & white and sepia previews of the selected image when the client chooses it as an option in the drop down menu. The problem I think I am having currently is setting the right path to the photo or possibly the placement of the code. Here where the image shows up on the php page: echo "<img src=\"watermark.php?i=" . $photo->id . "\" class=\"photos\">"; This is the code for watermark.php: <?PHP //INCLUDE FILES NEEDED TO GET SETTINGS AND WATERMARK include( "database.php" ); include( "functions.php" ); $i = mysql_real_escape_string($_GET['i']); if($_GET['i'] != "" && !is_numeric($_GET['i'])){ header("location: error.php?error=i"); exit; } //GET PHOTO INFO $photo_result = mysql_query("SELECT filename FROM uploaded_images where id = '$i' order by original", $db); $photo = mysql_fetch_object($photo_result); //ADDED FOR SECURITY if($photo->filename != ""){ //DECLARE THIS AS AN IMAGE header("Content-type: image/jpeg"); $image = imagecreatefromjpeg('$photo->filename'); imagefilter($image, IMG_FILTER_GRAYSCALE); imagejpeg($image, 'grayscale.jpeg); imagedestroy($image); //GET SETTINGS $setting_result = mysql_query("SELECT show_watermark,sample_display_quality,sample_width,photo_dir FROM settings where id = '1' limit 1", $db); $setting = mysql_fetch_object($setting_result); //GET WATERMARK if($setting->show_watermark == "1"){ $water_img = "./images/watermark.png"; } else { $water_img = "./images/watermark_off.png"; } //QUALITY LEVEL AND PHOTO PATH $quality = $setting->sample_display_quality; $stock_photo_path = "./" . $setting->photo_dir . "/"; watermark($stock_photo_path . "s_" . $photo->filename,"sample",$water_img,$quality,$setting->sample_width); } ?> As of right now no image will appear in the preview with this code, but when I take out the imagefilter code the original image displays fine. I don't know if I have the proper coding for the path to the image or if I have the imagefilter function in the wrong spot. Thanks for any advice. Link to comment https://forums.phpfreaks.com/topic/117015-using-php-imagefilter-with-images-from-mysql/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.