gdlib

Using the PHP GD library to resize and save images is HELL

喜欢而已 提交于 2019-12-05 15:45:52
I'm writing a script that will upload a file from user input, resize it to a thumbnail and add the two new filenames to a database. However, I cannot for the life of me figure out how to get PHP to detect the image's MIME type and then give it to the header. Here is the code, I've put comments to try and make it as clear as possible: $picture = $_FILES['picture']['name']; /*original file location*/ $file = 'picture/'.$picture.''; /*save thumbnail location*/ $save = 'thumb/tn-'.$picture.''; /*append thumbnail filename with tn-*/ $thumb = 'tn-'.$picture.''; /*get original file size*/ list($width

Image curving with PHP or HTML5

佐手、 提交于 2019-12-05 15:05:33
I am looking to achieve: http://i53.tinypic.com/2gule04.jpg I have tried the answers mentioned at Curving an image that starts as a rectangle (uploaded by user), preferably using Canvas or JS Based on the answers there, I have tried pixel wise transformation which didn't work. To understand a mesh based approach, you will need a skill set of 3d-2d developer which I don't possess. I am a PHP developer and I am looking for an answer in either PHP or HTML5. I have tried number of things ranging from HTML5 canvas to splitting the image into smaller parts and then joining them however those don't

In PHP, imagepng() accepts a filter parameter. How do these filters affect the function's output?

為{幸葍}努か 提交于 2019-12-05 11:39:38
问题 How do these filters affect the output of imagepng() in PHP? PNG_NO_FILTER PNG_FILTER_NONE PNG_FILTER_SUB PNG_FILTER_UP PNG_FILTER_AVG PNG_FILTER_PAETH PNG_ALL_FILTERS The documentation simply says, "A special PNG filter, used by the imagepng() function" for each of them. It seems that using PNG_NO_FILTER will reduce the filesize of the output, but other than that, I am unsure as to how it is affected. Any insight would be really appreciated. 回答1: According to the PNG Specifications at http:/

Extract words from an Image and PDF - Laravel [closed]

北慕城南 提交于 2019-12-04 17:16:45
is there any way to extract words from scanned images and PDF? Is there any such library for Laravel as I want to use it for laravel. I have searched a lot for that but did not found any such thing for Laravel. Please let me know if you are aware about it. Every help would be highly appreciated :-). Thanks to all of you in advance !!!! joshuamabina After doing some reading... Its possible to read text from scanned images and PDF. I too couldn't find libraries for image processing built for explicit use with laravel, but I did find PHP wrappers for the infamous OpenCV and TesseractOCR , maybe

In PHP, imagepng() accepts a filter parameter. How do these filters affect the function's output?

[亡魂溺海] 提交于 2019-12-03 23:33:47
How do these filters affect the output of imagepng() in PHP? PNG_NO_FILTER PNG_FILTER_NONE PNG_FILTER_SUB PNG_FILTER_UP PNG_FILTER_AVG PNG_FILTER_PAETH PNG_ALL_FILTERS The documentation simply says, "A special PNG filter, used by the imagepng() function" for each of them. It seems that using PNG_NO_FILTER will reduce the filesize of the output, but other than that, I am unsure as to how it is affected. Any insight would be really appreciated. According to the PNG Specifications at http://www.w3.org/TR/PNG-Filters.html The purpose of these filters is to prepare the image data for optimum

PHP GD library used to merge two images

本秂侑毒 提交于 2019-12-02 15:17:16
问题 Okay, so I have two images in a file. One of them is of a t-shirt. The other is of a logo. I used CSS to style the two images so that it looks like the logo is written on the t-shirt. I merely gave the image of a logo a higher z-index in the CSS style sheet. Is there anyway that I could generate an image of both the shirt and the image combined as one using the GD library? Thanks, Lance 回答1: It's possible. Sample code: // or whatever format you want to create from $shirt = imagecreatefrompng(

PHP image creation from hex values in database

拟墨画扇 提交于 2019-12-02 12:38:46
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_error()); while($colors = mysql_fetch_array( $sql )) { $x = 0; $imgname = $x.".jpg"; $color = $colors[

PHP GD library used to merge two images

末鹿安然 提交于 2019-12-02 10:14:09
Okay, so I have two images in a file. One of them is of a t-shirt. The other is of a logo. I used CSS to style the two images so that it looks like the logo is written on the t-shirt. I merely gave the image of a logo a higher z-index in the CSS style sheet. Is there anyway that I could generate an image of both the shirt and the image combined as one using the GD library? Thanks, Lance Thiago Silveira It's possible. Sample code: // or whatever format you want to create from $shirt = imagecreatefrompng("shirt.png"); // the logo image $logo = imagecreatefrompng("logo.png"); // You need a

Take screenshot with openGL and save it as png

╄→гoц情女王★ 提交于 2019-12-01 19:17:12
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 SVimage2file(char *filename){ int width = glutGet(GLUT_SCREEN_WIDTH); int height = glutGet( GLUT_SCREEN

How to create an image with transparent background

≯℡__Kan透↙ 提交于 2019-11-30 12:53:12
问题 How to create an image with GDlib with a transparent background? header('content-type: image/png'); $image = imagecreatetruecolor(900, 350); imagealphablending($image, true); imagesavealpha($image, true); $text_color = imagecolorallocate($image, 0, 51, 102); imagestring($image,2,4,4,'Test',$text_color); imagepng($image); imagedestroy($image); Here the background is black 回答1: You have to use imagefill() and fill that with allocated color ( imagecolorallocatealpha() ) that have alpha set to 0.