SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot jrickards's Avatar
    Join Date
    May 2003
    Location
    Sudbury
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP-resized image doesn't display

    Hi:

    I searched and found some PHP image resizing code and got it to partly work for me.

    If you go to http://sqlcourse.jrickards.ca/includ...48&imgSize=250, you can see a resized image. The original image is 450x450 and the resizing properly resizes it to 250x250.

    However, when you go to http://sqlcourse.jrickards.ca/produc...prodid=0480048, the same image should show up in the main area where the error messages exist but obviously, it doesn't.

    In the products.php page, I have:

    Code:
    <p><?php include_once("includes/resize_image.php?imgID=0480048&imgSize=250"); ?></p>
    I expected that the image would appear in the middle area because the resize script works fine.

    Is it a path issue? The calling page, /products.php is in the root folder and the includes folder is /includes and the photos are in /photos. I have tried moving the resize script to the same folder as the photos but no difference in results.

    The resize script is:

    Code:
    <?php
    	$origImg = imagecreatefromjpeg("../photos/" . $_GET['imgID'] . ".jpg");
    	$imageSize = $_GET['imgSize'];
    	$resizedImg = imagecreate($imageSize, $imageSize);
    	imagecopyresampled($resizedImg, $origImg, 0, 0, 0, 0, $imageSize, $imageSize, 450, 450);
    	header("Content-type: image/jpeg");
    	imagejpeg($resizedImg);
    ?>
    Any help would be appreciated.

    Jules

  2. #2
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try
    Code:
    <img src="includes/resize_image.php?imgID=0480048&imgSize=250">

  3. #3
    SitePoint Zealot jrickards's Avatar
    Join Date
    May 2003
    Location
    Sudbury
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JRMillion
    try
    Code:
    <img src="includes/resize_image.php?imgID=0480048&imgSize=250">
    That's it (major slap on the head)!!!

    However, some strangeness still occurs: the colours are off on the resized images.

  4. #4
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use ImageCreateTrueColor()
    instead of imagecreate()

  5. #5
    SitePoint Zealot jrickards's Avatar
    Join Date
    May 2003
    Location
    Sudbury
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent! Many thanks.

  6. #6
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no problem, ive been there


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •