1
<?php
$f = new SaeFetchurl();
$img_data = $f->fetch( 'http://ss7.sinaimg.cn/bmiddle/488efcbbt7b5c4ae51ca6&690' );
$img = new SaeImage();
$img->setData( $img_data );
$img->resize(200); 
$img->flipH(); 
$img->flipV(); 
$new_data = $img->exec();
$img->exec( 'jpg' , true );

if ($new_data === false)
        var_dump($img->errno(), $img->errmsg());
?>

Here is the code from sina sae. It offers images service. When I paste the code on my page, I just can see the mess in the browser.

What does this "$img->exec( 'jpg' , true );" mean?

How to output the images using php?

fredley
  • 32,953
  • 42
  • 145
  • 236
CashLee李秉骏
  • 1,038
  • 1
  • 10
  • 23

3 Answers3

3

With mess you mean a bunch of characters?

Try to set the header information

header('Content-type: image/jpeg');
Alex
  • 32,506
  • 16
  • 106
  • 171
0

The mess might be the interpreted image (code). You might want to include the php script into the src attribute of an html image tag.

Like:

<img src="foobar.php?optional=params" />
0

just adding on to Alex. I been using this over the past new days and I've noticed that my images will not be shown on the page without the extra 2 lines below.

    header('Content-type: image/jpeg');
    imagepng($img);
    imagedestroy($img);
jemiloii
  • 24,594
  • 7
  • 54
  • 83