Jump to content

Joshua4550

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

About Joshua4550

  • Birthday 03/21/1993

Profile Information

  • Gender
    Not Telling

Joshua4550's Achievements

Member

Member (2/5)

0

Reputation

  1. Figured. Created a PHP script which grabs the url defined in a _GET parameter, and used file_get_contents() to display the script output. This made me able to request a post to that script on the same domain. I posted back just to allow any future people looking for the answer to this to find. Thanks anyway
  2. Hey, So. I wanted to post to an external script (cross-domain) in JavaScript. This is not my domain, though it's a partner. I figured it would be SO MUCH easier to just post using jQuery's $.post() method, and problem solved. Well done! The problem was solved, until I ran it in IE - uh oh, IE doesn't like it? I researched this problem, and it seems it's an IE security problem with cross-domain blahblah. My question? How would I go about achieving the exact same result (just to post to the script, without actually making the user run it?) - I am not actually posting any _POST or _GET variables, I was only using $.post() because it was a convenient solution. My old attempt, which IE didn't like? $.post('http://External_Site.com/External_Script.php'); (Obviously that isn't the real URL) Any help? Much appreciation for all help =)
  3. Is that how scripts such as forums normally do it? Yes. When they log in, it stores username/user id in a session (Eg: $_SESSION['mysite_logid']) and then providing you start sessions for the relative page, you can use that session to tell your next script the logged in user's username/ID.
  4. That code works, so if you're fine with when they're setting.. I'd say it's fine to use them that way.
  5. I'm guessing you don't understand that i'm not uploading. I'm using the GD library to create an image resource stored in a variable from two existing images. But yeah.. I need to make it construct on the www but then save the image to a subdomain such as images.example.com (saving using the imagepng() function btw) Guessing I should pass the image resource through to another script located on the subdomain, just not sure how I would go about passing it through. Thanks in advance to anyone who helps
  6. Depends what you're putting in makeimage.php and which subdomain (www or images) each script goes on. Explain (BTW: I meant subdomain, not subdirectory -.-)
  7. Hey. I'm just wondering what would be the most logical or most efficient way to save an image resource that has been constructed on say the www. to a subdirectory or on another webserver? For eg The script on www.example.com constructs an image using the GD library from image1.png and image2.png. It has now got the final image resource for what's been constructed. I now want to save this image onto images.example.com How would you suggest?
  8. Right, so I got the code to work - but the background isn't transparrent, anyone know why? function fitToCanvas($img) { $size = getimagesize($img); $width = $size[0]; $height = $size[1]; $img_resource = imagecreatefrompng($img); $widths = array(); $heights = array(); $count = 0; for ($i = 0; $i < $height; $i++) { for ($j = 0; $j < $width; $j++) { $colorAt = imagecolorat($img_resource, $j, $i); $colorIndex = imagecolorsforindex($img_resource, $colorAt); if ($colorIndex['alpha']!=127) { // Not transparrent, load this pixel into the array $count++; $widths[$count] = $j; $heights[$count] = $i; } } } $bottom_right = array(max($widths), max($heights)); $top_left = array(min($widths), min($heights)); $image_size = array($bottom_right[0]-$top_left[0], $bottom_right[1]-$top_left[1]); $img2 = imagecreatetruecolor($image_size[0], $image_size[1]); $im = imagecopy($img2, $img_resource, 0, 0, $top_left[0], $top_left[1], $image_size[0], $image_size[1]); imagedestroy($img_resource); return $img2; }
  9. Ookay, I got the image to print - but now it's a black canvas. I'll work on fixing this atm, but does anyone see where my method code goes wrong?
  10. Okay, I tried this before - but it gave me the following error: The image “http://mysite.com/test/” cannot be displayed, because it contains errors. Atm, here's my codes: (I've tried multiple ways around this, but not found a working one) function fitToCanvas($img) { $size = getimagesize($img); $width = $size[0]; $height = $size[1]; $img_resource = imagecreatefrompng($img); $widths = array(); $heights = array(); $count = 0; for ($i = 0; $i < $height; $i++) { for ($j = 0; $j < $width; $j++) { $colorAt = imagecolorat($img_resource, $j, $i); $colorIndex = imagecolorsforindex($img_resource, $colorAt); if ($colorIndex['alpha']!=127) { // Not transparrent, load this pixel into the array $count++; $widths[$count] = $j; $heights[$count] = $i; } } } $bottom_right = array(max($widths), max($heights)); $top_left = array(min($widths), min($heights)); $image_size = array($bottom_right[0]-$top_left[0], $bottom_right[1]-$top_left[1]); $img2 = imagecreatetruecolor($image_size[0], $image_size[1]); imagecopy($img2, $img_resource, 0, 0, 0, 0, $image_size[0], $image_size[1]); imagedestroy($img_resource); return $img2; } header('Content-type: image/png'); echo '<img src="lolhi.png" title="" />'; $img = fitToCanvas("lolhi.png"); imagepng($img); echo '<br /><br />'; echo '<img src="fgt.png" title="" />'; $img = fitToCanvas("fgt.png"); imagepng($img); echo '<br /><br />'; I know the method isn't most efficient, was going to go and seek help with improving it if it runs slow, later on. Any idea how to move this around to make the header not give me errors, and not give the "headers already sent" error?
  11. Hey, I was recently refferred to a few of the GD functions to complete a task I asked if was possible or not - and i'm SO close to finishing. I have the method polished up, I just need to find out why my image is not outputting. I made the script crop the image and copy it onto the blank canvas, but when I try to output it, it simply outputs: ‰PNG ��� IHDR���ƒ���i���– Õ���?IDATxœíÁ1��� õOm ? ����������������������������������������^¡š�$û����IEND®B`‚ Does anyone know the general/most common causes of this? Just need to fix and I'm done =)
  12. Thank you so much, i'll start looking into it right now =)
×
×
  • 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.