"imageJPEG" create thumbnails help!

Discussion in 'PHP' started by php-lover, Oct 23, 2006.

  1. #1
    Hey guys can someone help me in how to print directly the image to the browser.

    Here is my code

    $sourcePath = "C:/Server/Apache/htdocs/project/".$file_source;
    $thumbWidth = $target_size;


    $sourceImage = imagecreatefromjpeg($sourcePath);
    $sourceWidth = imagesx($sourceImage);
    $sourceHeight = imagesy($sourceImage);

    $targetImage = imagecreate($thumbWidth,$thumbWidth);
    imagecopyresized($targetImage,$sourceImage,0,0,0,0,$thumbWidth,
    $thumbWidth,imagesx($sourceImage),imagesy($sourceImage));
    ($targetImage,'',90);

    imageJPEG($targetImage,'',90); // As though output to browser.


    I run this code and its display a raw of data in my screen without image....

    ©#å2¤‚}k¡øñª-TÔ,®í´»¾a*O#­ºlSò’±‘¸äòqÓè*ÖpN{œî¬dùv>¨Õ â]ØGlê–òÎVåY2YnÀ)ìwçÓ$j>ñºÖõ_Vì¥¡´i¥Úҳ‚ïê1‘Ó W©i?4½vÉ.ÒóN²ÜH0_]¬R) ÿLŠêt¥1Fª{Ÿ6M

    Can someone help me of how to fix this problem.....I just want to display the image to the browser.
     
    php-lover, Oct 23, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sounds like you have to set the header mime type with header().
     
    T0PS3O, Oct 23, 2006 IP
    Chemo likes this.
  3. Chemo

    Chemo Peon

    Messages:
    146
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Paste this before the imageJPEG line of code:
    
    header("Content-type: image/jpeg");
    
    PHP:
    Bobby
     
    Chemo, Oct 23, 2006 IP
  4. Chemo

    Chemo Peon

    Messages:
    146
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You beat me to the punch :)

    Bobby
     
    Chemo, Oct 23, 2006 IP
  5. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #5
    lol Chemo..I already try to send using header but still not work...maybe i am doing in a wrong way...

    header("Content-type: image/jpeg");
    imageJPEG($targetImage,'',90);


    is that the right format?
     
    php-lover, Oct 23, 2006 IP