开发者

php gd script not outputting picture correctly

开发者 https://www.devze.com 2023-02-06 17:25 出处:网络
This Code saves the image like it\'s suppose to, but instead of displaying it as a picture, 开发者_开发百科what is displayed is a line of text inside the picture. help?

This Code saves the image like it's suppose to, but instead of displaying it as a picture, 开发者_开发百科what is displayed is a line of text inside the picture. help?

<?php

    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $opacity);


    // print image to screen
    header("content-type: image/jpeg");
    imagejpeg($image, "modified-images/".$codigo2."_modified_picture_status_".$status.".jpg");
    imagedestroy($image);  
    imagedestroy($watermark);

    ?>


If you are using the second parameter of imagejpeg, the image will not be outputted to the browser but ONLY saved to the file. Try omitting the second parameter if you don't need to save it as a file, and it should output directly to the browser.

If you want to do both, try a print(file_get_contents($imagepath)) after your current block of code. $imagepath should obviously contain the path that you wrote the image to.


make two lines:

// save image
imagejpeg($image, "modified-images/".$codigo2."_modified_picture_status_".$status.".jpg");
// output image
imagejpeg($image);
0

精彩评论

暂无评论...
验证码 换一张
取 消