gdlib

Convert image format PNG to JPEG without saving to disk - PHP

不打扰是莪最后的温柔 提交于 2019-12-29 09:18:09
问题 I am taking a PNG image from a url as below. I want to convert the PNG image to JPEG without saving disk with PHP. Finally I want to assign JPEG image to $content_jpg variable. $url = 'http://www.example.com/image.png'; $content_png = file_get_contents($url); $content_jpg=; 回答1: You want to use the gd library for this. Here's an example which will take a png image and output a jpeg one. If the image is transparent, the transparency will be rendered as white instead. <?php $file = "myimage.png

PHP GD Library cannot Merge to image using function

喜夏-厌秋 提交于 2019-12-25 03:04:33
问题 This is my php class to merge to images mergepic.php class mergepic{ public function merge_barchart_drawing($object,$obj) { $src = imagecreatefrompng($obj->barchart()); $dest = imagecreatefrompng($object->drawing()); //$src = imagecreatefrompng('http://localhost/graph/barchart.php?barchart='.$_GET['barchart'].'&max='.$_GET['max'].'&digit='.$_GET['digit']); //$dest = imagecreatefrompng('http://localhost/graph/drawing.php?drawings='.$_GET['drawings'].'&max='.$_GET['max'].'&digit='.$_GET['digit'

Estimate required memory for libGD operation

南笙酒味 提交于 2019-12-24 04:26:22
问题 Before attempting to resize an image in PHP using libGD, I'd like to check if there's enough memory available to do the operation, because an "out of memory" completely kills the PHP process and can't be catched. My idea was that I'd need 4 byte of memory for each pixel (RGBA) in the original and in the new image: // check available memory if(!is_mem_available(($from_w * $from_h * 4) + ($to_w * $to_h * 4))){ return false; } Tests showed that this much more memory than the library really seem

PHP image creation from hex values in database

一曲冷凌霜 提交于 2019-12-20 05:42:15
问题 I've got the code below to pull hex values from a database and create an image of that colour. There's over a thousand values, so it's looping to create an image for them all. It seems to work fine except it just keeps overwriting the first image (0.jpg) instead of creating new ones 0.jpg, 1.jpg 2.jpg etc. Any idea where I'm going wrong? Oh yeah, I'm converting the hex to rgb in there too, that works fine. <?php require ('connect.php'); $sql = mysql_query("SELECT * FROM hex") or die(mysql

Take screenshot with openGL and save it as png

最后都变了- 提交于 2019-12-19 19:56:50
问题 I'm trying to take a screenshot of full screen and save it as a png. I found a code here and modified it a bit. For the screenshot I use openGL and Glut and for the saving in png the gd library for c. All I'm getting is a black png and I can't figure out why. I searched in stackoverflow and found some posts, but unfortunately they didn't help. One of them was to use glReadBuffer( GL_FRONT); instead of glReadBuffer(GL_BACK); I tryed with both of them with no success. Here is my code: int

Face detection in PHP

核能气质少年 提交于 2019-12-18 10:55:30
问题 Does anybody know of a good way to do face detection in PHP? I came across some code here that claims to do this, but I can't seem to get it to work properly. I'd like to make this work (even though it will be slow) and any help you can give me would be really appreciated. Here's the code from the link: <?php // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be

Face detection in PHP

南楼画角 提交于 2019-12-18 10:55:21
问题 Does anybody know of a good way to do face detection in PHP? I came across some code here that claims to do this, but I can't seem to get it to work properly. I'd like to make this work (even though it will be slow) and any help you can give me would be really appreciated. Here's the code from the link: <?php // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be