php - GD Library image creation problem -


i having problem gd library issue. when use following code

<script type="text/javascript">  $.fn.infinitecarousel = function () {      function repeat(str, num) {         return new array( num + 1 ).join( str );     }      return this.each(function () {         var $wrapper = $('> div', this).css('overflow', 'hidden'),             $slider = $wrapper.find('> ul'),             $items = $slider.find('> li'),             $single = $items.filter(':first'),              singlewidth = $single.outerwidth(),              visible = math.ceil($wrapper.innerwidth() / singlewidth), // note: doesn't include padding or border             currentpage = 1,             pages = math.ceil($items.length / visible);                       // 1. pad 'visible' number seen, otherwise create empty items         if (($items.length % visible) != 0) {             $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));             $items = $slider.find('> li');         }          // 2. top , tail list 'visible' number of items, top has last section, , tail has first         $items.filter(':first').before($items.slice(- visible).clone().addclass('cloned'));         $items.filter(':last').after($items.slice(0, visible).clone().addclass('cloned'));         $items = $slider.find('> li'); // reselect          // 3. set left position first 'real' item         $wrapper.scrollleft(singlewidth * visible);          // 4. paging function         function gotopage(page) {             var dir = page < currentpage ? -1 : 1,                 n = math.abs(currentpage - page),                 left = singlewidth * dir * visible * n;              $wrapper.filter(':not(:animated)').animate({                 scrollleft : '+=' + left             }, 500, function () {                 if (page == 0) {                     $wrapper.scrollleft(singlewidth * visible * pages);                     page = pages;                 } else if (page > pages) {                     $wrapper.scrollleft(singlewidth * visible);                     // reset start position                     page = 1;                 }                   currentpage = page;             });                              return false;         }          $wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');          // 5. bind forward , buttons         $('a.back', this).click(function () {             return gotopage(currentpage - 1);                         });          $('a.forward', this).click(function () {             return gotopage(currentpage + 1);         });          // create public interface move specific page         $(this).bind('goto', function (event, page) {             gotopage(page);         });     });   };  $(document).ready(function () {   $('.infinitecarousel').infinitecarousel();    $("a.picturethumb").fancybox({         'autoscale'     : true,         'autodimension' : true,         'transitionin'  :   'elastic',         'transitionout' :   'elastic',         'speedin'       :   300,          'speedout'      :   200,          'hideonoverlayclick' : true,          'hideoncontentclick': false      }); }); </script> 

with image generator, thing comes out looks programming code instead of image. script worked different scroller, since put new scroller script (seen above), having problems generating image (ie shows loading icon), firefox shows programming code.

here code making call gd function:

<div class="infinitecarousel">   <div class="wrapper">         <ul>           <?php        { ?>           <li><a class="picturethumb" href="picture.php?imgid=<?php $pieces = explode('_', $row_rspictures['picturefile']); echo $pieces[0]."_".$pieces[1]."_".$pieces[2]; if ($pieces[3] == "nn"){ echo "_nn_".$pieces[4]."_".$pieces[5];; } else { echo "_".$pieces[3]."_".$pieces[4]; } ?>&thumb=y" title="&lt;a href=&#x27;addtocart.php?t=pic?id=<?php echo $row_rspictures['pictureid']; ?>&#x27; target=&#x27;_parent&#x27; style=&#x27;color:#fe6d00&#x27;  &gt;add image shopping cart&lt;/a&gt;<br><?php echo $row_rspictures['boatname'];if($row_rspictures['boatnumber'] != "") {                                      echo " #".$row_rspictures['boatnumber'];                                      } ?><br>driven by: <?php echo $row_rspictures['drivername']; ?> @ <?php                   $assocname_array = explode('_', $row_rspictures['acronym']);                   $assocname = $assocname_array[0];                   if ($assocname == "various") {                     $assocname = "";                     }                               if ($row_rspictures['dateto'] != ""){                   $eventyear = date("y", strtotime($row_rspictures['dateto']));                   }                     else { $eventyear = "";                     }                   echo $eventyear." ".$assocname." ".$row_rspictures['eventname'];?><br>picture viewed (<?php echo $row_rspictures['views']; ?>) since posted on <?php echo date("n-j-y", strtotime($row_rspictures['dateposted'])); ?>" rel="group">             <img src="../images/gallery/<?php $raceyear = explode('_', $row_rspictures['eventoverlay']); echo $raceyear[0]; ?>/<?php echo $row_rspictures['eventoverlay']; ?>/thumb/<?php echo $row_rspictures['picturefile']; ?>.jpg" alt="filename: <?php echo $row_rspictures['picturefile'];?>"></a></li>           <?php             } while ($row_rspictures = mysql_fetch_assoc($rspictures));           mysql_data_seek($rspictures, 0);           ?>         </ul>       </div>   </div> 

and separate php file generates image.

<?php   $filename = explode("_", $_get['imgid']); $folder = $filename[0]; $subfolder = $filename[0]."_".$filename[1]."_".$filename[2]; if($filename[3] == "nn") {     $subfolder = $subfolder."_nn";     } $shot = "../images/gallery/".$folder."/".$subfolder."/".$_get['imgid'].".jpg"; $watermark = "../images/gallery/watermark.png";  header("content-type: image/jpg"); $photoimage = imagecreatefromjpeg($shot);  imagealphablending($photoimage, true);  $logoimage2 = imagecreatefrompng($watermark);  $im = imagecreatetruecolor(800, 16); $im2 = imagecreatetruecolor(800, 10); $white = imagecolorallocate($im, 255, 255, 255); //imagefilledrectangle($photoimage, 0, 0, 796, 15, $white); $grey = imagecolorallocate($im2, 128, 128, 128); $red = imagecolorallocate($im2, 255, 0, 0); //$im = imagecreatetruecolor(796, 25); $text = $_get['imgid']; $text2 = 'copyright 1997 - 2011 - dragboats.com - rights reserved'; $text3 = '^ bar not appear on purchased prints ^'; //$black = imagecolorallocate($photoimage, 0, 0, 0); imagestring($im, 2, 10, 1, $text, $white); imagestring($im, 2, 440, 1, $text2, $white); imagestring($im2, 1, 290, 1, $text3, $white);  imagecopy($photoimage, $im, 0, 0, 0, 0, 800, 16); imagecopy($photoimage, $im2, 0, 17, 0, 0, 800, 10); imagecopy($photoimage, $logoimage2, 0, 0, 0, 0, 800, 525);   imagejpeg($photoimage); // output browser   imagedestroy($photoimage);  imagedestroy($logoimage2); ?> 

somewhere there conflict causing problem , can't find it.

any appreciated.

the actual page can found @ http://randykrohn.com/gallery/pictures_test.php?boatid=881

it appears you're outputting raw image data (the bytes in .jpg) file gallery popup, innappropriate header imgae being interpreted text , not image.

if last chunk of code under "... call gd function" in 1 file, explain why. you're outputting chunk of html, followed raw image data, gets inserted gallery popup. content-type header cannot take effect you've output html. if check error logs (and/or enable errors/warnings), you'd no doubt see usual "cannot modify headers, output started @ line xxx" warnings php.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -