webster08 Posted June 13, 2011 Share Posted June 13, 2011 So I am still working on a basic advert; still got to do some tweaking, but have ran into a kind of weird situation. I set the base GD image's ($im) height to 2550; then I started adding images with imagecopymerge(). Well... I realized that I needed to re-size my images because they were taking up to much space and making my base image to tall; plus the file size was getting stupid ridiculous. So... then I started using imagecopyresized(); well all went well until about the 6th image, that I re-sized. Then; here's where the problem comes in; the 7th, 8th, and 9th image, that I re-sized, would not display at all. So I started playing around with the height of the base image and came to find out, that as I reduced the base image's height; the other 3 images displayed. I finally had to change the base height image to 1760; in order for all the images to display in the base image. So has anyone ever had this to happen and is there a work around; other then reducing my re-sized images even more? I would like to be able to display all the re-sized images and still be able to make my advert taller/longer (increase the height beyond 1760); so that I can add more text as needed. This is a totally different question, but while I'm here... I figure what not. I have a wordwrap() to check to make sure the $bodyText is not overflowing in a straight line (from one side of the image to the other), but it is not wrapping the first line with the same boundries; as it's wrapping the rest of the string. The top line is extending further; then the rest of the wrapped string/lines. Does anyone have any advice about how to fix this, as well? PS: I know right now; I only have "Basic Details Here" in the $bodyText variable, but in testing.... I add a very long string. <?php // set the HTTP header type to PNG header("Content-type: image/png"); // set the width and height of the new image in pixels $width = 1000; $height = 2550; // create a pointer to a new true colour image $im = imagecreatetruecolor($width, $height); // text $mainTitle="2011 Chrystler Town And Country LX"; $bodyText="Basic Details Here"; $price="X Amount of Dollars Here"; $di="Phone: | Website: | Email: "; // font path $font = 'arial.ttf'; // color $red = ImageColorAllocate($im, 255, 0, 0); // sets background to white $white = ImageColorAllocate($im, 255, 255, 255); ImageFillToBorder($im, 0, 0, $white, $white); // define a black colour $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 525, 100, $white); //word wrap $warpText = wordwrap($bodyText, 85, "\n", true); // display text on image imagettftext($im, 35, 0, 100, 70, $black, $font, $mainTitle); imagettftext($im, 25, 0, 375, 2500, $red, $font, "Price = ".$price); imagettftext($im, 14, 0, 100, 150, $black, $font, "Dealership Information: ".$di); imagettftext($im, 14, 0, 100, 190, $black, $font, "Vehicle Description: ".$warpText); // current gd image, font size, angle, left position, top position, color, font family, text // make a new line and add it to the image ImageLine($im, 0, 100, 1000, 100, $black); // draw rectangle ImageRectangle($im, 0, 0, $width-1, $height-1, $black); // add photos // define urls $pic1="2011-Chysler-Town-And-Country-LX-driver.JPG"; $pic2="2011-Chysler-Town-And-Country-LX-pass.JPG"; $pic3="2011-Chysler-Town-And-Country-LX-front.JPG"; $pic4="2011-Chysler-Town-And-Country-LX-back.JPG"; $pic5="2011-Chysler-Town-And-Country-LX-int-driver-front.JPG"; $pic6="2011-Chysler-Town-And-Country-LX-int-driver-back.JPG"; $pic7="2011-Chysler-Town-And-Country-LX-int-pass-front.JPG"; $pic8="2011-Chysler-Town-And-Country-LX-int-pass-back.JPG"; $pic9="2011-Chysler-Town-And-Country-LX-engine.JPG"; // create images $pic1 = imagecreatefromjpeg($pic1); $pic2 = imagecreatefromjpeg($pic2); $pic3 = imagecreatefromjpeg($pic3); $pic4 = imagecreatefromjpeg($pic4); $pic5 = imagecreatefromjpeg($pic5); $pic6 = imagecreatefromjpeg($pic6); // it will not resize & display past here $pic7 = imagecreatefromjpeg($pic7); $pic8 = imagecreatefromjpeg($pic8); $pic9 = imagecreatefromjpeg($pic9); // display photo in this image imagecopymerge($im, $pic1, 180, 500, 0, 0, 640, 480, 100); // resize and display photos in this image imagecopyresized($im, $pic2, 180, 980, 0, 0, 320, 240, 640, 480); imagecopyresized($im, $pic3, 500, 980, 0, 0, 320, 240, 640, 480); imagecopyresized($im, $pic4, 180, 1220, 0, 0, 320, 240, 640, 480); imagecopyresized($im, $pic5, 500, 1220, 0, 0, 320, 240, 640, 480); imagecopyresized($im, $pic6, 180, 1460, 0, 0, 320, 240, 640, 480); imagecopyresized($im, $pic7, 500, 1460, 0, 0, 320, 240, 640, 480); // it will not resize & display past here imagecopyresized($im, $pic8, 180, 1700, 0, 0, 320, 240, 640, 480); imagecopyresized($im, $pic9, 500, 1700, 0, 0, 320, 240, 640, 480); // destroy the reference pointer to the image in memory to free up resources ImageDestroy($pic1); ImageDestroy($pic2); ImageDestroy($pic3); ImageDestroy($pic4); ImageDestroy($pic5); ImageDestroy($pic6); ImageDestroy($pic7); ImageDestroy($pic8); ImageDestroy($pic9); imagepng($im); ImageDestroy($im); ?> Link to comment https://forums.phpfreaks.com/topic/239205-imagecopyresized-issue-with-base-gd-image-height/ Share on other sites More sharing options...
QuickOldCar Posted June 13, 2011 Share Posted June 13, 2011 I guess it could be limits involving memory for those large images. as for the wordwrap: use this: $warpText = wordwrap($bodyText, 85, "<br />", true); Link to comment https://forums.phpfreaks.com/topic/239205-imagecopyresized-issue-with-base-gd-image-height/#findComment-1228941 Share on other sites More sharing options...
webster08 Posted June 13, 2011 Author Share Posted June 13, 2011 I guess it could be limits involving memory for those large images. QuickOldCar, that's what I am thinking to, but it's only 640X480 images. I just wonder if there is a "work around" for this kind of thing. as for the wordwrap: use this: $warpText = wordwrap($bodyText, 85, "<br />", true); The "<br />" are not in the string, so it did not recognize them or it didn't understand html elements; either way... it just spit out 1 long line of text, that did not wrap lol. Link to comment https://forums.phpfreaks.com/topic/239205-imagecopyresized-issue-with-base-gd-image-height/#findComment-1228942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.