gd

PHP/GD: How to handle jpg transparency?

点点圈 提交于 2021-01-29 07:16:25
问题 JPG doesn't support transparency. Yet you can export an image with transparent areas from for example GIMP. In that case the transparent areas will show either black or white in your browser, Windows explorer or other software. I regularly receive such files that I need to process and provide in several smaller formats. I do that with some PHP script using the GD library. The problem is that it is unpredictable whether those areas will turn out black or white in the processed versions. Even

Call to undefined function imagewebp()

≯℡__Kan透↙ 提交于 2021-01-29 05:57:39
问题 I am wondering why i get this error. I updated my php from 5.6.22 to 5.6.40 and now i get this error. This was working fine in previous version but suddenly it turns out like this. Fatal error: Call to undefined function imagewebp() Also if try var_dump(function_exists('imagewebp')); it gives false now. This is my current PHP version This is the GD Module So what has to be done to re-enable it in my server. I have a Cent-OS instance in AWS. 回答1: The WBMP Support => enabled is not enough) You

How to output images using php?

痞子三分冷 提交于 2021-01-29 03:50:46
问题 <?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(

php , gd, create watermark, change watermark text size and background color, imagecreatefromjpeg

杀马特。学长 韩版系。学妹 提交于 2020-07-02 03:12:12
问题 I need to create a watermark apply it on a picture and save it with a different name . The current script works pretty well but the only problem is that I need to increase the size of the "sample text" and change the background from black to white . I tried different scenarios , changed the opacity but still can't change the background color. function watermark($imag_path, $photo_id) { // Load the stamp and the photo to apply the watermark to $im = imagecreatefromjpeg("$imag_path"); echo

php , gd, create watermark, change watermark text size and background color, imagecreatefromjpeg

♀尐吖头ヾ 提交于 2020-07-02 03:12:12
问题 I need to create a watermark apply it on a picture and save it with a different name . The current script works pretty well but the only problem is that I need to increase the size of the "sample text" and change the background from black to white . I tried different scenarios , changed the opacity but still can't change the background color. function watermark($imag_path, $photo_id) { // Load the stamp and the photo to apply the watermark to $im = imagecreatefromjpeg("$imag_path"); echo

php , gd, create watermark, change watermark text size and background color, imagecreatefromjpeg

只愿长相守 提交于 2020-07-02 03:12:01
问题 I need to create a watermark apply it on a picture and save it with a different name . The current script works pretty well but the only problem is that I need to increase the size of the "sample text" and change the background from black to white . I tried different scenarios , changed the opacity but still can't change the background color. function watermark($imag_path, $photo_id) { // Load the stamp and the photo to apply the watermark to $im = imagecreatefromjpeg("$imag_path"); echo

PHP HTML image output

两盒软妹~` 提交于 2020-05-10 04:17:12
问题 In the PHP manual for base64_encode() I saw the following script for outputting an image. <?php $imgfile = "test.gif"; $handle = fopen($filename, "r"); $imgbinary = fread(fopen($imgfile, "r"), filesize($imgfile)); echo '<img src="data:image/gif;base64,' . base64_encode($imgbinary) . '" />'; ?> But how can you output an image dynamically created with GD? I've tried this: $im = imagecreatetruecolor(400, 400); imagefilledrectangle($im, 0, 0, 200, 200, 0xFF0000); imagefilledrectangle($im, 200, 0,