Jump to content

webster08

Members
  • Posts

    111
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

webster08's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I really don't have a clue, as to what your looking for; but since no one else responded to you and because I am bored, lol... I am going to try to give it a shot. Try something like this; maybe it will get you started: <script> var created, created2 = "no"; function getImage(imgName) { var image1 = new Image(); image1.setAttribute("id","Photo 1"); image1.setAttribute("src","pic1.jpg"); image1.setAttribute("width","1"); image1.setAttribute("height","1"); var image2 = new Image(); image2.setAttribute("id","Photo 2"); image2.setAttribute("src","pic2.jpg"); image2.setAttribute("width","1"); image2.setAttribute("height","1"); // validation if (imgName == "Photo 1") { // insert image only once into page if (created != "yes") { document.body.appendChild(image1); created = "yes"; } var imgSRC = document.getElementById(""+imgName+"").src; alert(imgSRC); // for example purposes } else if (imgName == "Photo 2") { // insert image only once into page if (created2 != "yes") { document.body.appendChild(image2); created2 = "yes"; } var imgSRC = document.getElementById(""+imgName+"").src; alert(imgSRC); // for example purposes } } </script> <button onclick="getImage('Photo 1')">See The SRC For "Photo 1"</button> <button onclick="getImage('Photo 2')">See The SRC For "Photo 2"</button> If you play around with it some; I am sure you can cut down on some of the code recursion, but maybe this will help you out... at least for demo purposes. If you have some code to post; that will probably help people to understand what you trying to do and will, in turn... get more responses to your question.
  2. Oh... ok... here we go... I got it.... figured it out. Here is the final code: <?php header('content-type: text/plain text'); $watermark = imagecreatefrompng('watermark.png'); $watermark2 = imagecreatefromgif('watermark.gif'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // here is the fix $watermark_width2 = imagesx($watermark2); $watermark_height2 = imagesy($watermark2); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($_GET['src']); $size = getimagesize($_GET['src']); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, 1, 0, 0, 0, $watermark_width, $watermark_height, 65); imagecopymerge($image, $watermark2, 1, 0, 0, 0, $watermark_width2, $watermark_height2, 65); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); imagedestroy($watermark2); ?> Thanks for the help mjdamato!
  3. I tried your code mjdamato; but it still does not display the second watermark. The second watermark is a transparent gif; so it should not cover the main image. So here's what I got with your code: <?php header('content-type: text/plain text'); $watermark = imagecreatefrompng('watermark.png'); $watermark2 = imagecreatefromgif('watermark.gif'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($_GET['src']); $size = getimagesize($_GET['src']); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; imagecopymerge($image, $watermark, 1, 0, 0, 0, $watermark_width, $watermark_height, 65); imagecopymerge($image, $watermark2, 1, 0, 0, 0, $watermark_width, $watermark_height, 65); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); imagedestroy($watermark2); ?> That is actually what I did at first; the code you presented, but I added in the variable $pic, because the original two lines were not working.
  4. I am trying to add two watermarks to one image, but the second watermark is not being merged. Can anyone help me correct my code or send me in the right directions; to correcting this issue? PS: I know that the header is set to plain text, but I have a reason for that. <?php header('content-type: text/plain text'); $watermark = imagecreatefrompng('watermark.png'); $watermark2 = imagecreatefromgif('watermark.gif'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatetruecolor($watermark_width, $watermark_height); $image = imagecreatefromjpeg($_GET['src']); $size = getimagesize($_GET['src']); $dest_x = $size[0] - $watermark_width - 5; $dest_y = $size[1] - $watermark_height - 5; $pic = imagecopymerge($image, $watermark, 1, 0, 0, 0, $watermark_width, $watermark_height, 65); imagecopymerge($pic, $watermark2, 1, 0, 0, 0, $watermark_width, $watermark_height, 65); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); imagedestroy($watermark2); ?>[code=php:0]
  5. 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. 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.
  6. 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); ?>
  7. WOW! Thank You So Much AlexWD; That Is Exactly What I Was Wanting To Do!
  8. Hey AlexWD, thank you for the reply. Yeah... I looked at that function, but I am having problems figuring out how to incorporate that into my current code. The example in the manual is rather vague; when it comes to inserting an image into your current image. Would I need to create a totally different php file to do this or can I incorporate something like the example (that the manual gives) into my current code?
  9. Ok... let me see if I can get the ball rolling then. Is it possible for me to do this (in some way); with the imagelayereffect() global GD function?
  10. I am trying to create a completely PHP GD image based advert, so far I am able to add shapes, lines, and text. The next step is to directly embed an image(s) into my base PHP GD image advert. Here's where the problem comes in; I'm not sure how to go about doing this. I don't want to create a separate php file to watermark the main image with external images. I want to be able to directly embed images into the base image. Can anyone advise as to what would be way to accomplish this; my code is below? <?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 = 1000; // create a pointer to a new true colour image $im = imagecreatetruecolor($width, $height); // text $mainTitle="2011 Chrystler Town And Country LX"; // font path $font = 'arial.ttf'; // 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); // display text on image imagettftext($im, 35, 0, 100, 70, $black, $font, $mainTitle); // make a new line and add it to the image ImageLine($im, 0, 100, 1000, 100, $black); // draw rectangle ImageRectangle($im, 0, 0, 999, 999, $black); // add image $pic1="2011-Chysler-Town-And-Country-pic1.jpg"; imagecreatefromjpeg($im, $pic1, 0, 0, 640, 480, 50); // send the new PNG image to the browser ImagePNG($im); // destroy the reference pointer to the image in memory to free up resources imagepng($im); ImageDestroy($im); ?> This is the piece of code that I know is not correct; this is where I need help at. // add image $pic1="2011-Chysler-Town-And-Country-pic1.jpg"; imagecreatefromjpeg($im, $pic1, 0, 0, 640, 480, 50);
  11. objects have not replaced iframe; each are probably used equally, but not for what your wanting to do. i really have never seen anyone include a html page in a object. one of the main reasons for that is; you can have more control over an iframe. it's up to you what you want to use to display your content, but it is not going to be as easy to manipulate an object, as it would be for any type of frame.
  12. it does change it; i know for a fact it does, because i have done this before and i tested the example i proved before i posted the idea for you. but whatever works - glad you got it to work out
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.