Asperon Posted September 4, 2007 Share Posted September 4, 2007 here is my code, my png comes with the encrypted data, I know that without html, it would view fine, and I know that <img> from another file would work... but is there another way to create these images in the situation that I have set up? <?php //get coupon info $query2 = "SELECT couponID,startDate,clicks,active,endDate,location FROM coupons WHERE businessID='$bID'"; $result2 = mysql_query($query2) or die('QUery failed: ' . mysql_error()); $rows = mysql_affected_rows(); //coupon print function function printCoupon($loc){ // The file $filename = $loc; $percent = 0.5; // Content type header('Content-type: image/png'); // Get new dimensions list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height * $percent; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Output imagepng($image_p); } // Printing results in HTML echo "<p> </p>"; echo "<table border='1' align='center'>\n"; echo "<tr align='center'>\n"; echo "<td>Coupon ID</td>\n"; echo "<td>Creation Date</td>\n"; echo "<td>Clicks</td>\n"; echo "<td>Active</td>\n"; echo "<td>End Date</td>\n"; echo "<td>Coupon</td>\n"; for($i=0; $i <= $rows-1; $i++){ echo "<tr align='center'>\n"; echo "<td>" . mysql_result($result2,$i,'couponID') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'startDate') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'clicks') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'active') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'endDate') . "</td>\n"; echo "<td>" . printCoupon(mysql_result($result2,$i,'location')) . "</td>\n"; echo "\t</tr>\n"; } echo "</table>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/67955-solved-gd-resampling/ Share on other sites More sharing options...
Asperon Posted September 4, 2007 Author Share Posted September 4, 2007 I figured it out..here's my code <?php //get coupon info $query2 = "SELECT couponID,startDate,clicks,active,endDate,location FROM coupons WHERE businessID='$bID'"; $result2 = mysql_query($query2) or die('Query failed: ' . mysql_error()); $rows = mysql_affected_rows(); // Printing results in HTML echo "<p> </p>"; echo "<table border='1' align='center'>\n"; echo "<tr align='center'>\n"; echo "<td>Coupon ID</td>\n"; echo "<td>Creation Date</td>\n"; echo "<td>Clicks</td>\n"; echo "<td>Active</td>\n"; echo "<td>End Date</td>\n"; echo "<td>Coupon</td>\n"; for($i=0; $i <= $rows-1; $i++){ $loc = mysql_result($result2,$i,'location'); $dim = getimagesize($loc); $width = $dim[0]*.5; $height= $dim[1]*.5; echo "<tr align='center'>\n"; echo "<td>" . mysql_result($result2,$i,'couponID') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'startDate') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'clicks') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'active') . "</td>\n"; echo "<td>" . mysql_result($result2,$i,'endDate') . "</td>\n"; echo "<td><img src='$loc' width=$width height=$height></img></td>\n"; echo "\t</tr>\n"; ImageDestroy($image_p); } echo "</table>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/67955-solved-gd-resampling/#findComment-341569 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.